From 18760e222a607a8b1ab6f4277e568ad0e93ee411 Mon Sep 17 00:00:00 2001 From: Jason Ish Date: Wed, 3 Feb 2016 14:28:50 -0600 Subject: [PATCH] asn1: fix memory leak As reported in issue #1395, fix 2 memory leaks when destroying asn.1 decode contexts. --- src/util-decode-asn1.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) 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); } -- 2.47.2