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 ac
SCFree(ac);
so the memory of asn1_stack will leak
the second:
in SCAsn1Decode of SCAsn1Decode
if (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 add
SCFree(ac->asn1_stack)
the second memory leak, should modified i < ac->cur_frame
to i <= ac->cur_frame