]> git.ipfire.org Git - thirdparty/zlib-ng.git/commitdiff
Fixed undefined behavior of isgraph when character is not in the range 0 through...
authorNathan Moinvaziri <nathan@nathanm.com>
Tue, 17 Aug 2021 17:12:37 +0000 (10:12 -0700)
committerHans Kristian Rosbach <hk-github@circlestorm.org>
Fri, 3 Sep 2021 09:21:09 +0000 (11:21 +0200)
trees.c
trees_emit.h

diff --git a/trees.c b/trees.c
index 2a5e2de946ace32ef03cb3172ff7a3ab2b0c696a..5ff07636f424826a307011862be26b1a0ee3a36d 100644 (file)
--- 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));
     }
 }
 
index 52af7a409d38ae99c17776d3913fd74e3f03b14d..c957770878db753a2d7e94f64c46600e937b2aeb 100644 (file)
@@ -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;
 }