diff options
author | Yann Collet <cyan@fb.com> | 2017-04-09 08:11:39 (GMT) |
---|---|---|
committer | Yann Collet <cyan@fb.com> | 2017-04-09 08:11:39 (GMT) |
commit | 7eecd32c079cdf1afda8c00bba83dd3a1fee3f62 (patch) | |
tree | 38b4556d5983336ff86b7d6d4263b1b587004ef2 | |
parent | e169edac054941c4019880d88b243821f8a10414 (diff) | |
download | lz4-7eecd32c079cdf1afda8c00bba83dd3a1fee3f62.zip lz4-7eecd32c079cdf1afda8c00bba83dd3a1fee3f62.tar.gz lz4-7eecd32c079cdf1afda8c00bba83dd3a1fee3f62.tar.bz2 |
ensure lz4f_cctx internal buffer size remain valid in case of malloc error
-rw-r--r-- | lib/lz4frame.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/lz4frame.c b/lib/lz4frame.c index 7c1b8fd..fc0c7b5 100644 --- a/lib/lz4frame.c +++ b/lib/lz4frame.c @@ -445,10 +445,11 @@ size_t LZ4F_compressBegin(LZ4F_cctx* cctxPtr, void* dstBuffer, size_t dstCapacit requiredBuffSize = (cctxPtr->prefs.frameInfo.blockMode == LZ4F_blockLinked) * 64 KB; /* just needs dict */ if (cctxPtr->maxBufferSize < requiredBuffSize) { - cctxPtr->maxBufferSize = requiredBuffSize; + cctxPtr->maxBufferSize = 0; FREEMEM(cctxPtr->tmpBuff); cctxPtr->tmpBuff = (BYTE*)ALLOCATOR(requiredBuffSize); if (cctxPtr->tmpBuff == NULL) return err0r(LZ4F_ERROR_allocation_failed); + cctxPtr->maxBufferSize = requiredBuffSize; } cctxPtr->tmpIn = cctxPtr->tmpBuff; cctxPtr->tmpInSize = 0; |