summaryrefslogtreecommitdiffstats
path: root/lib/lz4frame.c
diff options
context:
space:
mode:
authorYann Collet <Cyan4973@users.noreply.github.com>2019-04-23 17:18:40 (GMT)
committerGitHub <noreply@github.com>2019-04-23 17:18:40 (GMT)
commit398e36c756a3067de8e2b35dd380baef040dfe0d (patch)
treefe7d22f46d7345bf1316a91c2eedad4765f997f1 /lib/lz4frame.c
parent131896ab9d4fc9b8c606616327ed223d5d86472b (diff)
parentf665291e6cb651cb084bf9450a071ae0fd494782 (diff)
downloadlz4-1.9.1.zip
lz4-1.9.1.tar.gz
lz4-1.9.1.tar.bz2
Merge pull request #692 from lz4/devv1.9.1
v1.9.1
Diffstat (limited to 'lib/lz4frame.c')
-rw-r--r--lib/lz4frame.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/lib/lz4frame.c b/lib/lz4frame.c
index 42124e9..a10e4af 100644
--- a/lib/lz4frame.c
+++ b/lib/lz4frame.c
@@ -325,8 +325,7 @@ static size_t LZ4F_compressBound_internal(size_t srcSize,
const LZ4F_preferences_t* preferencesPtr,
size_t alreadyBuffered)
{
- LZ4F_preferences_t prefsNull;
- MEM_INIT(&prefsNull, 0, sizeof(prefsNull));
+ LZ4F_preferences_t prefsNull = LZ4F_INIT_PREFERENCES;
prefsNull.frameInfo.contentChecksumFlag = LZ4F_contentChecksumEnabled; /* worst case */
{ const LZ4F_preferences_t* const prefsPtr = (preferencesPtr==NULL) ? &prefsNull : preferencesPtr;
U32 const flush = prefsPtr->autoFlush | (srcSize==0);
@@ -1065,7 +1064,10 @@ struct LZ4F_dctx_s {
LZ4F_errorCode_t LZ4F_createDecompressionContext(LZ4F_dctx** LZ4F_decompressionContextPtr, unsigned versionNumber)
{
LZ4F_dctx* const dctx = (LZ4F_dctx*)ALLOC_AND_ZERO(sizeof(LZ4F_dctx));
- if (dctx==NULL) return err0r(LZ4F_ERROR_GENERIC);
+ if (dctx == NULL) { /* failed allocation */
+ *LZ4F_decompressionContextPtr = NULL;
+ return err0r(LZ4F_ERROR_allocation_failed);
+ }
dctx->version = versionNumber;
*LZ4F_decompressionContextPtr = dctx;