summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorIrwan Djajadi <irwan.djajadi@ni.com>2016-04-19 13:22:56 (GMT)
committerIrwan Djajadi <irwan.djajadi@ni.com>2016-04-19 13:22:56 (GMT)
commit973baa2c191629458a454dc75bdb251255b4a402 (patch)
tree43978427e6dc661e16e65aa37b20dfa6135d2d94 /lib
parent8a42ee10a331da493eeee9ebea533acc08cd023c (diff)
parent3e5bb67537da4e93c13fdaf9ae5d04b0afef3c5a (diff)
downloadlz4-973baa2c191629458a454dc75bdb251255b4a402.zip
lz4-973baa2c191629458a454dc75bdb251255b4a402.tar.gz
lz4-973baa2c191629458a454dc75bdb251255b4a402.tar.bz2
Merge branch 'heapmode_alloc_failure_fix' into dev
Diffstat (limited to 'lib')
-rw-r--r--lib/lz4.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/lz4.c b/lib/lz4.c
index 39bf5d6..cd0776b 100644
--- a/lib/lz4.c
+++ b/lib/lz4.c
@@ -731,6 +731,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)
@@ -963,6 +967,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)
@@ -980,6 +988,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;
@@ -1541,6 +1550,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;
}