diff options
author | Irwan Djajadi <irwan.djajadi@ni.com> | 2016-04-18 20:51:32 (GMT) |
---|---|---|
committer | Irwan Djajadi <irwan.djajadi@ni.com> | 2016-04-18 20:51:32 (GMT) |
commit | 3e5bb67537da4e93c13fdaf9ae5d04b0afef3c5a (patch) | |
tree | a24de435a658b6cdaec41c86eb1ffa3f1afa74ed /lib | |
parent | d86dc916771c126afb797637dda9f6421c0cb998 (diff) | |
download | lz4-3e5bb67537da4e93c13fdaf9ae5d04b0afef3c5a.zip lz4-3e5bb67537da4e93c13fdaf9ae5d04b0afef3c5a.tar.gz lz4-3e5bb67537da4e93c13fdaf9ae5d04b0afef3c5a.tar.bz2 |
alloc failure fix
Diffstat (limited to 'lib')
-rw-r--r-- | lib/lz4.c | 10 |
1 files changed, 10 insertions, 0 deletions
@@ -685,6 +685,10 @@ int LZ4_compress_fast(const char* source, char* dest, int inputSize, int maxOutp void* ctxPtr = &ctx; #endif +#if (HEAPMODE) + if (!ctxPtr) { return 0; } +#endif + int result = LZ4_compress_fast_extState(ctxPtr, source, dest, inputSize, maxOutputSize, acceleration); #if (HEAPMODE) @@ -918,6 +922,10 @@ int LZ4_compress_destSize(const char* src, char* dst, int* srcSizePtr, int targe void* ctx = &ctxBody; #endif +#if (HEAPMODE) + if (!ctx) { return 0; } +#endif + int result = LZ4_compress_destSize_extState(ctx, src, dst, srcSizePtr, targetDstSize); #if (HEAPMODE) @@ -935,6 +943,7 @@ int LZ4_compress_destSize(const char* src, char* dst, int* srcSizePtr, int targe LZ4_stream_t* LZ4_createStream(void) { LZ4_stream_t* lz4s = (LZ4_stream_t*)ALLOCATOR(8, LZ4_STREAMSIZE_U64); + if (!lz4s) { return NULL; } LZ4_STATIC_ASSERT(LZ4_STREAMSIZE >= sizeof(LZ4_stream_t_internal)); /* A compilation error here means LZ4_STREAMSIZE is not large enough */ LZ4_resetStream(lz4s); return lz4s; @@ -1489,6 +1498,7 @@ int LZ4_resetStreamState(void* state, char* inputBuffer) void* LZ4_create (char* inputBuffer) { void* lz4ds = ALLOCATOR(8, LZ4_STREAMSIZE_U64); + if (!lz4ds) { return NULL; } LZ4_init ((LZ4_stream_t_internal*)lz4ds, (BYTE*)inputBuffer); return lz4ds; } |