summaryrefslogtreecommitdiffstats
path: root/lib/lz4.c
diff options
context:
space:
mode:
authorYann Collet <cyan@fb.com>2020-09-26 18:31:57 (GMT)
committerYann Collet <cyan@fb.com>2020-09-26 18:31:57 (GMT)
commitee4f37d2840c1faa41fb7110bbf6d1e58bf30ace (patch)
treeb1b330a8246b826f84dc48bdc4982fcdbe833d8e /lib/lz4.c
parent20856da7c571cc1ee55965a342527f8263dc356d (diff)
downloadlz4-ee4f37d2840c1faa41fb7110bbf6d1e58bf30ace.zip
lz4-ee4f37d2840c1faa41fb7110bbf6d1e58bf30ace.tar.gz
lz4-ee4f37d2840c1faa41fb7110bbf6d1e58bf30ace.tar.bz2
fix compressing into NULL
fails properly bug discovered by oss-fuzz
Diffstat (limited to 'lib/lz4.c')
-rw-r--r--lib/lz4.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/lib/lz4.c b/lib/lz4.c
index 2222d53..d21eef4 100644
--- a/lib/lz4.c
+++ b/lib/lz4.c
@@ -1236,6 +1236,7 @@ LZ4_FORCE_INLINE int LZ4_compress_generic(
if ((U32)srcSize > (U32)LZ4_MAX_INPUT_SIZE) { return 0; } /* Unsupported srcSize, too large (or negative) */
if (srcSize == 0) { /* src == NULL supported if srcSize == 0 */
+ if (outputDirective != notLimited && dstCapacity <= 0) return 0; /* no output, can't write anything */
DEBUGLOG(5, "Generating an empty block");
assert(outputDirective == notLimited || dstCapacity >= 1);
assert(dst != NULL);