summaryrefslogtreecommitdiffstats
path: root/lib/lz4.c
diff options
context:
space:
mode:
authorW. Felix Handte <w@felixhandte.com>2018-03-12 22:32:24 (GMT)
committerW. Felix Handte <w@felixhandte.com>2018-03-12 22:35:09 (GMT)
commit5149767a1b3caba4c17c0e79247c6092f7ae23ef (patch)
treee7cfb2662d338d6e2a6a85ff82d5e462932d7d2b /lib/lz4.c
parent299f34909a2da7dc7096747e1c62cfe3994ec467 (diff)
downloadlz4-5149767a1b3caba4c17c0e79247c6092f7ae23ef.zip
lz4-5149767a1b3caba4c17c0e79247c6092f7ae23ef.tar.gz
lz4-5149767a1b3caba4c17c0e79247c6092f7ae23ef.tar.bz2
Add NULL Checks
Diffstat (limited to 'lib/lz4.c')
-rw-r--r--lib/lz4.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/lib/lz4.c b/lib/lz4.c
index 6a680e6..822d572 100644
--- a/lib/lz4.c
+++ b/lib/lz4.c
@@ -889,6 +889,7 @@ int LZ4_compress_fast(const char* source, char* dest, int inputSize, int maxOutp
int result;
#if (LZ4_HEAPMODE)
LZ4_stream_t* ctxPtr = ALLOC(sizeof(LZ4_stream_t)); /* malloc-calloc always properly aligned */
+ if (ctxPtr == NULL) return 0;
#else
LZ4_stream_t ctx;
LZ4_stream_t* const ctxPtr = &ctx;
@@ -1101,6 +1102,7 @@ int LZ4_compress_destSize(const char* src, char* dst, int* srcSizePtr, int targe
{
#if (LZ4_HEAPMODE)
LZ4_stream_t* ctx = (LZ4_stream_t*)ALLOC(sizeof(LZ4_stream_t)); /* malloc-calloc always properly aligned */
+ if (ctx == NULL) return 0;
#else
LZ4_stream_t ctxBody;
LZ4_stream_t* ctx = &ctxBody;
@@ -1125,6 +1127,7 @@ LZ4_stream_t* LZ4_createStream(void)
LZ4_stream_t* lz4s = (LZ4_stream_t*)ALLOC(sizeof(LZ4_stream_t));
LZ4_STATIC_ASSERT(LZ4_STREAMSIZE >= sizeof(LZ4_stream_t_internal)); /* A compilation error here means LZ4_STREAMSIZE is not large enough */
DEBUGLOG(4, "LZ4_createStream %p", lz4s);
+ if (lz4s == NULL) return NULL;
LZ4_resetStream(lz4s);
return lz4s;
}