]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
asn1: fix memory leak
authorJason Ish <ish@unx.ca>
Wed, 3 Feb 2016 20:28:50 +0000 (14:28 -0600)
committerVictor Julien <victor@inliniac.net>
Mon, 8 Feb 2016 08:20:38 +0000 (09:20 +0100)
As reported in issue #1395, fix 2 memory leaks when destroying
asn.1 decode contexts.

src/util-decode-asn1.c

index 3372b517cec46f04052725778ff706b220400aef..4e4115a104ff44a97f0205b356cddb7a56581bbb 100644 (file)
@@ -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);
 }