summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorW. Felix Handte <w@felixhandte.com>2017-10-11 20:13:33 (GMT)
committerW. Felix Handte <w@felixhandte.com>2018-03-12 18:58:43 (GMT)
commit6d156fea56debbde1699b54a52c4907ff0b96017 (patch)
treef552f33c82396aeafa89be85fcb1ef07dfa6b3b7 /lib
parent8c006b19bbed0b3bb2466dc8af2a603ca0ba7fab (diff)
downloadlz4-6d156fea56debbde1699b54a52c4907ff0b96017.zip
lz4-6d156fea56debbde1699b54a52c4907ff0b96017.tar.gz
lz4-6d156fea56debbde1699b54a52c4907ff0b96017.tar.bz2
Allow Empty Dictionaries
Diffstat (limited to 'lib')
-rw-r--r--lib/lz4.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/lib/lz4.c b/lib/lz4.c
index 38a865f..898b82a 100644
--- a/lib/lz4.c
+++ b/lib/lz4.c
@@ -1018,12 +1018,6 @@ int LZ4_loadDict (LZ4_stream_t* LZ4_dict, const char* dictionary, int dictSize)
if ((dict->initCheck) || (dict->currentOffset > 1 GB)) /* Uninitialized structure, or reuse overflow */
LZ4_resetStream(LZ4_dict);
- if (dictSize < (int)HASH_UNIT) {
- dict->dictionary = NULL;
- dict->dictSize = 0;
- return 0;
- }
-
if ((dictEnd - p) > 64 KB) p = dictEnd - 64 KB;
dict->currentOffset += 64 KB;
base = p - dict->currentOffset;
@@ -1031,6 +1025,10 @@ int LZ4_loadDict (LZ4_stream_t* LZ4_dict, const char* dictionary, int dictSize)
dict->dictSize = (U32)(dictEnd - p);
dict->currentOffset += dict->dictSize;
+ if (dictSize < (int)HASH_UNIT) {
+ return 0;
+ }
+
while (p <= dictEnd-HASH_UNIT) {
LZ4_putPosition(p, dict->hashTable, byU32, base);
p+=3;