Actions
Bug #1359
closedmemory leak
Affected Versions:
Effort:
Difficulty:
Label:
Description
fix up the memory leak in ans1 match
Files
Actions
Added by wei xuan almost 11 years ago. Updated over 9 years ago.
Description
fix up the memory leak in ans1 match
Files
util-decode-asn1.c (23 KB) util-decode-asn1.c | for memory leak of ans1 match | wei xuan, 01/09/2015 08:12 PM |
there are two memory leak in SCAsn1CtxDestroy
the first:
the malloc memory in SCAsn1CtxNew in util-decode-asn1.c
ac->asn1_stack = SCMalloc(sizeof(Asn1Node *) * asn1_max_frames_config);
but when destory in SCAsn1CtxDestroy in util-decode-asn1.c, only free acSCFree(ac);
so the memory of asn1_stack will leak
the second:
in SCAsn1Decode of SCAsn1Decodeif (SCAsn1CtxNewFrame(ac, node_id) == NULL)
break;
ac->cur_frame = node_id;
this code in while, for example, if the while run twice, malloc two node, the cur_frame is only 1
but SCAsn1CtxDestroy in util-decode-asn1.c for (; i < ac->cur_frame; i++) {
Asn1Node *node = ASN1CTX_GET_NODE(ac, i);
if (node != NULL) {
SCFree(node);
}
}
when we free the node in SCAsn1Decode , the last node we don't free, so memory leak here.
repair them,
the frist memory leak, should addSCFree(ac->asn1_stack)
the second memory leak, should modified i < ac->cur_frame
to i <= ac->cur_frame
Jason can you check this in master and 2.0.8? If stable is affected we'll need a separate ticket for that.