summaryrefslogtreecommitdiffstats
path: root/lib/lz4hc.c
diff options
context:
space:
mode:
authorW. Felix Handte <w@felixhandte.com>2018-04-20 23:35:51 (GMT)
committerW. Felix Handte <w@felixhandte.com>2018-04-20 23:35:51 (GMT)
commit85cac61dd8823886132b4a9c2ff4a43b237da917 (patch)
tree3d54804b95a48f670664cb1fa39e1f1bd88d61e3 /lib/lz4hc.c
parent756ed402da8161c7bc3749bebaac069259312d8b (diff)
downloadlz4-85cac61dd8823886132b4a9c2ff4a43b237da917.zip
lz4-85cac61dd8823886132b4a9c2ff4a43b237da917.tar.gz
lz4-85cac61dd8823886132b4a9c2ff4a43b237da917.tar.bz2
Don't Segfault on Malloc Failure
Diffstat (limited to 'lib/lz4hc.c')
-rw-r--r--lib/lz4hc.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/lib/lz4hc.c b/lib/lz4hc.c
index a973086..b0325a7 100644
--- a/lib/lz4hc.c
+++ b/lib/lz4hc.c
@@ -830,9 +830,11 @@ int LZ4_compress_HC_destSize(void* LZ4HC_Data, const char* source, char* dest, i
/* allocation */
LZ4_streamHC_t* LZ4_createStreamHC(void) {
LZ4_streamHC_t* LZ4_streamHCPtr = (LZ4_streamHC_t*)malloc(sizeof(LZ4_streamHC_t));
- LZ4_streamHCPtr->internal_donotuse.end = (const BYTE *)(ptrdiff_t)-1;
- LZ4_streamHCPtr->internal_donotuse.base = NULL;
- LZ4_streamHCPtr->internal_donotuse.dictCtx = NULL;
+ if (LZ4_streamHCPtr != NULL) {
+ LZ4_streamHCPtr->internal_donotuse.end = (const BYTE *)(ptrdiff_t)-1;
+ LZ4_streamHCPtr->internal_donotuse.base = NULL;
+ LZ4_streamHCPtr->internal_donotuse.dictCtx = NULL;
+ }
return LZ4_streamHCPtr;
}