Open ColinIanKing opened 7 months ago
Thanks! We will fix this issue. Jira ticket created: https://jira.devtools.intel.com/browse/QATAPP-31728
+1 to this. our code security scanner blames the same lines:
Defect type: CPPCHECK_WARNING: QATzip-1.2.0/test/main.c:2694: error[memleak]: Memory leak: orig_src QATzip-1.2.0/test/main.c:2694: error[memleak]: Memory leak: decomp_src QATzip-1.2.0/test/main.c:2694: error[memleak]: Memory leak: comp_src QATzip-1.2.0/test/main.c:2520: error[memleak]: Memory leak: orig_src QATzip-1.2.0/test/main.c:2520: error[memleak]: Memory leak: decomp_src QATzip-1.2.0/test/main.c:2520: error[memleak]: Memory leak: comp_src
so, orig_src
, comp_src
and decomp_src
can leak at test/main.c:2694
and test/main.c:2520
:
void *testqzEndStreamInvalidParam(void *arg, int test_no)
{
...
// ALLOC HERE
orig_src = malloc(orig_sz);
comp_src = malloc(comp_sz);
decomp_src = calloc(orig_sz, 1);
if (qzGetDefaults(&comp_params) != QZ_OK) {
QZ_ERROR("Err: fail to get default params.\n");
return NULL; //<-- LEAK HERE
}
and
void *testqzDecompressStreamInvalidParam(void *arg, int test_no)
{
...
// ALLOC HERE
orig_src = malloc(orig_sz);
comp_src = malloc(comp_sz);
decomp_src = calloc(orig_sz, 1);
if (qzGetDefaults(&comp_params) != QZ_OK) {
QZ_ERROR("Err: fail to get default params.\n");
return NULL; //<-- LEAK HERE
}
the return path in line 2694 is not free'ing the allocated objects orig_src, comp_src, decomp_src, leaking to (non-fatal) memory leaks.