From: Nathan Moinvaziri Date: Tue, 17 Aug 2021 17:12:37 +0000 (-0700) Subject: Fixed undefined behavior of isgraph when character is not in the range 0 through... X-Git-Tag: 2.1.0-beta1~517 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0af8678307ef2ab976454a50ae299281185ba2f5;p=thirdparty%2Fzlib-ng.git Fixed undefined behavior of isgraph when character is not in the range 0 through 0xFF inclusive. --- diff --git a/trees.c b/trees.c index 2a5e2de94..5ff07636f 100644 --- a/trees.c +++ b/trees.c @@ -308,7 +308,7 @@ Z_INTERNAL void gen_codes(ct_data *tree, int max_code, uint16_t *bl_count) { tree[n].Code = bi_reverse(next_code[len]++, len); Tracecv(tree != static_ltree, (stderr, "\nn %3d %c l %2d c %4x (%x) ", - n, (isgraph(n) ? n : ' '), len, tree[n].Code, next_code[len]-1)); + n, (isgraph(n & 0xff) ? n : ' '), len, tree[n].Code, next_code[len]-1)); } } diff --git a/trees_emit.h b/trees_emit.h index 52af7a409..c95777087 100644 --- a/trees_emit.h +++ b/trees_emit.h @@ -109,7 +109,7 @@ static inline uint32_t zng_emit_lit(deflate_state *s, const ct_data *ltree, unsi s->bi_valid = bi_valid; s->bi_buf = bi_buf; - Tracecv(isgraph(c), (stderr, " '%c' ", c)); + Tracecv(isgraph(c & 0xff), (stderr, " '%c' ", c)); return ltree[c].Len; }