summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorYann Collet <cyan@fb.com>2021-05-28 08:10:41 (GMT)
committerYann Collet <cyan@fb.com>2021-05-28 08:10:41 (GMT)
commitdfc431fb3d03bc8abceeff0aa9197fd165171561 (patch)
treeb8e0d0bea8fc7f3aee016dc67a4406875ce696cc /lib
parent539c783c98f1c9c6ad8db0a97da4295c36701ca7 (diff)
downloadlz4-dfc431fb3d03bc8abceeff0aa9197fd165171561.zip
lz4-dfc431fb3d03bc8abceeff0aa9197fd165171561.tar.gz
lz4-dfc431fb3d03bc8abceeff0aa9197fd165171561.tar.bz2
fix NULL ptr arithmetic at lz4:2299
Diffstat (limited to 'lib')
-rw-r--r--lib/lz4.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/lz4.c b/lib/lz4.c
index 9659962..62a6f6c 100644
--- a/lib/lz4.c
+++ b/lib/lz4.c
@@ -2298,8 +2298,13 @@ int LZ4_freeStreamDecode (LZ4_streamDecode_t* LZ4_stream)
int LZ4_setStreamDecode (LZ4_streamDecode_t* LZ4_streamDecode, const char* dictionary, int dictSize)
{
LZ4_streamDecode_t_internal* lz4sd = &LZ4_streamDecode->internal_donotuse;
- lz4sd->prefixSize = (size_t) dictSize;
- lz4sd->prefixEnd = (const BYTE*) dictionary + dictSize;
+ lz4sd->prefixSize = (size_t)dictSize;
+ if (dictSize) {
+ assert(dictionary != NULL);
+ lz4sd->prefixEnd = (const BYTE*) dictionary + dictSize;
+ } else {
+ lz4sd->prefixEnd = (const BYTE*) dictionary;
+ }
lz4sd->externalDict = NULL;
lz4sd->extDictSize = 0;
return 1;