summaryrefslogtreecommitdiffstats
path: root/lib/lz4.c
diff options
context:
space:
mode:
authorW. Felix Handte <w@felixhandte.com>2018-12-05 19:24:33 (GMT)
committerW. Felix Handte <w@felixhandte.com>2018-12-05 19:24:33 (GMT)
commit4e3accccb221c2e5dac90efec823a4b13fed70ae (patch)
treec6953a10cdc075f93a5b397ba3f74a6d55d469cb /lib/lz4.c
parent535636ff5cca702e4b5eb8e602c0ce70bfcde2c1 (diff)
downloadlz4-4e3accccb221c2e5dac90efec823a4b13fed70ae.zip
lz4-4e3accccb221c2e5dac90efec823a4b13fed70ae.tar.gz
lz4-4e3accccb221c2e5dac90efec823a4b13fed70ae.tar.bz2
Fix Dict Size Test in `LZ4_compress_fast_continue()`
Dictionaries don't need to be > 4 bytes, they need to be >= 4 bytes. This test was overly conservative. Also removes the test in `LZ4_attach_dictionary()`.
Diffstat (limited to 'lib/lz4.c')
-rw-r--r--lib/lz4.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/lib/lz4.c b/lib/lz4.c
index 87cbb99..53eff2e 100644
--- a/lib/lz4.c
+++ b/lib/lz4.c
@@ -1271,9 +1271,7 @@ void LZ4_attach_dictionary(LZ4_stream_t *working_stream, const LZ4_stream_t *dic
*/
LZ4_resetStream_fast(working_stream);
- if (dictionary_stream != NULL
- && dictionary_stream->internal_donotuse.dictSize - 1 >= 4
- /* intentional underflow */) {
+ if (dictionary_stream != NULL) {
/* If the current offset is zero, we will never look in the
* external dictionary context, since there is no value a table
* entry can take that indicate a miss. In that case, we need
@@ -1321,7 +1319,7 @@ int LZ4_compress_fast_continue (LZ4_stream_t* LZ4_stream, const char* source, ch
if (acceleration < 1) acceleration = ACCELERATION_DEFAULT;
/* invalidate tiny dictionaries */
- if ( (streamPtr->dictSize-1 < 4) /* intentional underflow */
+ if ( (streamPtr->dictSize-1 < 4-1) /* intentional underflow */
&& (dictEnd != (const BYTE*)source) ) {
DEBUGLOG(5, "LZ4_compress_fast_continue: dictSize(%u) at addr:%p is too small", streamPtr->dictSize, streamPtr->dictionary);
streamPtr->dictSize = 0;