From 990510c736b99c2e9480e6b5e54dd6eeb783cb80 Mon Sep 17 00:00:00 2001 From: kmannthe Date: Wed, 26 Aug 2020 12:39:21 -0700 Subject: [PATCH] Fix for "Uninitialized pointer in IntelDeflater.cc #89" Add an alloction and free block struct in question. Signed-off-by: Keith Mannthey --- src/main/native/compression/IntelDeflater.cc | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main/native/compression/IntelDeflater.cc b/src/main/native/compression/IntelDeflater.cc index 0b8b6971..b9ac93dd 100644 --- a/src/main/native/compression/IntelDeflater.cc +++ b/src/main/native/compression/IntelDeflater.cc @@ -164,9 +164,14 @@ JNIEXPORT void JNICALL Java_com_intel_gkl_compression_IntelDeflater_generateHuff jbyte* input = (jbyte*)env->GetPrimitiveArrayCritical(inputBuffer, 0); - struct isal_huff_histogram *histogram; + struct isal_huff_histogram *histogram = (struct isal_huff_histogram *) malloc(sizeof(*histogram)); struct isal_hufftables *hufftables_custom; + if (histogram == NULL) { + DBG ("Malloc failed out of memory"); + return; + } + memset(histogram, 0, sizeof(isal_huff_histogram)); isal_update_histogram((unsigned char*)input, 64*1024, histogram); isal_create_hufftables(hufftables_custom, histogram); @@ -174,7 +179,10 @@ JNIEXPORT void JNICALL Java_com_intel_gkl_compression_IntelDeflater_generateHuff env->SetLongField(obj, FID_lz_stream, (jlong)lz_stream); env->ReleasePrimitiveArrayCritical(inputBuffer, input, 0); + + free(histogram); } + } /**