diff options
author | Lasse Collin <lasse.collin@tukaani.org> | 2008-09-17 22:11:39 +0300 |
---|---|---|
committer | Lasse Collin <lasse.collin@tukaani.org> | 2008-09-17 22:11:39 +0300 |
commit | f147666a5cd15542d4e427da58629f4a71cc38e1 (patch) | |
tree | 323a66bc54ae265eca66e120c157c493ec52ba58 /src/liblzma/lz/lz_encoder.c | |
parent | LZ decoder cleanup (diff) | |
download | xz-f147666a5cd15542d4e427da58629f4a71cc38e1.tar.xz |
Miscellaneous LZ and LZMA encoder cleanups
Diffstat (limited to '')
-rw-r--r-- | src/liblzma/lz/lz_encoder.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/liblzma/lz/lz_encoder.c b/src/liblzma/lz/lz_encoder.c index 29a19a5d..159080ee 100644 --- a/src/liblzma/lz/lz_encoder.c +++ b/src/liblzma/lz/lz_encoder.c @@ -288,8 +288,12 @@ lz_encoder_prepare(lzma_mf *mf, lzma_allocator *allocator, return true; } - // Calculate the sizes of mf->hash and mf->son. + // Calculate the sizes of mf->hash and mf->son and check that + // find_len_max is big enough for the selected match finder. const uint32_t hash_bytes = lz_options->match_finder & 0x0F; + if (hash_bytes > mf->find_len_max) + return true; + const bool is_bt = (lz_options->match_finder & 0x10) != 0; uint32_t hs; @@ -351,7 +355,7 @@ lz_encoder_prepare(lzma_mf *mf, lzma_allocator *allocator, // Maximum number of match finder cycles mf->loops = lz_options->match_finder_cycles; if (mf->loops == 0) { - mf->loops = 16 + (lz_options->find_len_max / 2); + mf->loops = 16 + (mf->find_len_max / 2); if (!is_bt) mf->loops /= 2; } |