X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~mdw/git/mLib/blobdiff_plain/3618811496a6d131fd4bffa19e262c521d39e819..98ff9295493ed2b990f30768e11b18b6bc65eaa4:/codec/baseconv.c?ds=sidebyside diff --git a/codec/baseconv.c b/codec/baseconv.c index b7cb0a0..53949bb 100644 --- a/codec/baseconv.c +++ b/codec/baseconv.c @@ -28,8 +28,6 @@ /*----- Header files ------------------------------------------------------*/ #include -#include -#include #include #include "alloc.h" @@ -364,8 +362,8 @@ static int ctxn##_dodecode(ctxn##_ctx *ctx, \ case PC: \ if (f & CDCF_IGNEQMID) break; \ if (f & CDCF_NOEQPAD) goto badch; \ - if (st == ST_MAIN && \ - !(f & CDCF_IGNZPAD) && (a & ((1 << nb) - 1))) \ + if (st == ST_MAIN && !(f & CDCF_IGNZPAD) && \ + ((nb && !(nb%wd)) || (a & ((1 << nb) - 1)))) \ return (CDCERR_INVZPAD); \ st = ST_PAD; \ if (!(f & CDCF_IGNEQPAD)) { \ @@ -387,8 +385,8 @@ static int ctxn##_dodecode(ctxn##_ctx *ctx, \ } \ } \ } else { \ - if (st == ST_MAIN && \ - !(f & CDCF_IGNZPAD) && (a & ((1 << nb) - 1))) \ + if (st == ST_MAIN && !(f & CDCF_IGNZPAD) && \ + ((nb && !(nb%wd)) || (a & ((1 << nb) - 1)))) \ return (CDCERR_INVZPAD); \ if (!(f & (CDCF_IGNEQPAD | CDCF_IGNEQMID | CDCF_NOEQPAD)) && nb) \ return (CDCERR_INVEQPAD); \ @@ -419,7 +417,7 @@ static int ctxn##_dec(codec *c, const void *p, size_t sz, dstr *d) \ static void ctxn##_destroy(codec *c) \ { \ ctxn##_codec *bc = (ctxn##_codec *)c; \ - if (bc->ctx.indent) xfree((/*unconst*/ char *)bc->ctx.indent); \ + if (bc->ctx.indent) xfree(UNCONST(char, bc->ctx.indent)); \ DESTROY(bc); \ } \ \