From: Jason Ish Date: Wed, 3 Feb 2016 20:28:50 +0000 (-0600) Subject: asn1: fix memory leak X-Git-Tag: suricata-3.0.1RC1~171 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=18760e222a607a8b1ab6f4277e568ad0e93ee411;p=thirdparty%2Fsuricata.git asn1: fix memory leak As reported in issue #1395, fix 2 memory leaks when destroying asn.1 decode contexts. --- diff --git a/src/util-decode-asn1.c b/src/util-decode-asn1.c index 3372b517ce..4e4115a104 100644 --- a/src/util-decode-asn1.c +++ b/src/util-decode-asn1.c @@ -373,13 +373,15 @@ void SCAsn1CtxDestroy(Asn1Ctx *ac) if (ac == NULL) return; - uint16_t i = 0; - for (; i < ac->cur_frame; i++) { + for (uint16_t i = 0; i < asn1_max_frames_config; i++) { Asn1Node *node = ASN1CTX_GET_NODE(ac, i); - if (node != NULL) { - SCFree(node); + if (node == NULL) { + break; } + SCFree(node); } + + SCFree(ac->asn1_stack); SCFree(ac); }