]> wimlib.net Git - wimlib/commit
lcpit_matchfinder: fix limiting nice_match_len
authorEric Biggers <ebiggers3@gmail.com>
Sun, 14 Apr 2019 06:21:42 +0000 (23:21 -0700)
committerEric Biggers <ebiggers3@gmail.com>
Sun, 14 Apr 2019 06:21:42 +0000 (23:21 -0700)
commitdbc624d7663c4e159ab4c1f3eddd642b1c28014e
tree81c2931a9a8ddafc49093b6648188a21c7c7f5f1
parent2fd8bf9f1c54daa5680ad8998b2228a4db9bd6de
lcpit_matchfinder: fix limiting nice_match_len

The "normal" mode of the lcp-interval tree matchfinder supports finding
matches up to LCP_MAX bytes.  The "huge" mode, which is needed on
buffers larger than 64 MiB, supports up to HUGE_LCP_MAX bytes.
nice_match_len must be limited to the appropriate one of these values.

But nice_match_len is limited by lcpit_matchfinder_init().  That's
wrong, because it only knows whether huge mode *might* be used later,
based on max_bufsize.  Which mode to use is actually decided on a
buffer-by-buffer basis by lcpit_matchfinder_load_buffer().

Thus, limit nice_match_len in lcpit_matchfinder_load_buffer() instead.

This fixes a crash or incorrect output during LZMS compression with a
compression level > 50 and a chunk size > 64 MiB.
include/wimlib/lcpit_matchfinder.h
src/lcpit_matchfinder.c