summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathan Moinvaziri <nathan@nathanm.com>2021-08-17 10:12:37 -0700
committerHans Kristian Rosbach <hk-github@circlestorm.org>2021-12-24 12:52:14 +0100
commit141ca9055c65b062f65ac4fc35e5603e3a28b99d (patch)
tree7f2f185281a0179c102e29cf202e6a9d026b7d4c
parentf172e34eeed83c4bcfdd1c0c1db0d6c66450034a (diff)
Fixed undefined behavior of isgraph when character is not in the range 0 through 0xFF inclusive.
-rw-r--r--trees.c2
-rw-r--r--trees_emit.h2
2 files changed, 2 insertions, 2 deletions
diff --git a/trees.c b/trees.c
index efd4d49..c3d4849 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 = (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));
}
}
diff --git a/trees_emit.h b/trees_emit.h
index 2253cfb..3280845 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;
}