]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
debug: fix realloc error checking on flowbit print 720/head
authorVictor Julien <victor@inliniac.net>
Wed, 11 Dec 2013 12:26:55 +0000 (13:26 +0100)
committerVictor Julien <victor@inliniac.net>
Thu, 12 Dec 2013 14:59:58 +0000 (15:59 +0100)
detect.c:1074:17: warning: Potential leak of memory pointed to by \
                                field 'debuglog_flowbits_names'
                return;

Bug #1062.

src/detect.c

index 7c8f55a92293212f942ff28c878a0ef329ef1136..682c8bb4ff387ca47abecdcac91198edd1827e81 100644 (file)
@@ -1067,12 +1067,16 @@ static void AlertDebugLogModeSyncFlowbitsNamesToPacketStruct(Packet *p, DetectEn
 
         if (i == p->debuglog_flowbits_names_len) {
             p->debuglog_flowbits_names_len += MALLOC_JUMP;
-            p->debuglog_flowbits_names = SCRealloc(p->debuglog_flowbits_names,
+            const char **names = SCRealloc(p->debuglog_flowbits_names,
                                                    sizeof(char *) *
                                                    p->debuglog_flowbits_names_len);
-            if (p->debuglog_flowbits_names == NULL) {
+            if (names == NULL) {
+                SCFree(p->debuglog_flowbits_names);
+                p->debuglog_flowbits_names = NULL;
+                p->debuglog_flowbits_names_len = 0;
                 return;
             }
+            p->debuglog_flowbits_names = names;
             memset(p->debuglog_flowbits_names +
                    p->debuglog_flowbits_names_len - MALLOC_JUMP,
                    0, sizeof(char *) * MALLOC_JUMP);