diff options
author | W. Felix Handte <w@felixhandte.com> | 2018-03-12 22:32:24 (GMT) |
---|---|---|
committer | W. Felix Handte <w@felixhandte.com> | 2018-03-12 22:35:09 (GMT) |
commit | 5149767a1b3caba4c17c0e79247c6092f7ae23ef (patch) | |
tree | e7cfb2662d338d6e2a6a85ff82d5e462932d7d2b | |
parent | 299f34909a2da7dc7096747e1c62cfe3994ec467 (diff) | |
download | lz4-5149767a1b3caba4c17c0e79247c6092f7ae23ef.zip lz4-5149767a1b3caba4c17c0e79247c6092f7ae23ef.tar.gz lz4-5149767a1b3caba4c17c0e79247c6092f7ae23ef.tar.bz2 |
Add NULL Checks
-rw-r--r-- | lib/lz4.c | 3 |
1 files changed, 3 insertions, 0 deletions
@@ -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; } |