]> 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, 24 Dec 2021 11:52:14 +0000 (12:52 +0100)
trees.c
trees_emit.h

diff --git a/trees.c b/trees.c
index efd4d49fb9e58c21067778748c975fb04d1bab4d..c3d484950d0024cf1e3fbb7cd9c3a0a40cc15c31 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 = (uint16_t)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 2253cfb60584d9f84f8fce98a84fbe989c8a3311..3280845e1f31121eb7c8ceeffd09ff5d450a23bc 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;
 }