Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed ubsan error when building tree with no symbols. madler#782
When there are no symbols in the tree we skip build_tree calculations and emit a block using static tree with no codes. trees.c:357:19: runtime error: unsigned integer overflow: 0 - 1 cannot be represented in type 'unsigned long' #0 0x1000ed79b in build_tree trees.c:357 madler#1 0x1000ea3f5 in zng_tr_flush_block trees.c:649 madler#2 0x100090ab0 in deflate_slow deflate_slow.c:131 madler#3 0x1000572bc in zng_deflate deflate.c:990 madler#4 0x1000aecd3 in gz_comp gzwrite.c:125 madler#5 0x1000b05df in zng_gzclose_w gzwrite.c:511 madler#6 0x1000967a4 in zng_gzclose gzlib.c:253 madler#7 0x100004f70 in test_gzio example.c:133 madler#8 0x100010c5b in main example.c:1034 madler#9 0x7fff71f57cc8 in start+0x0 (libdyld.dylib:x86_64+0x1acc8)
- Loading branch information