]> git.ipfire.org Git - people/ms/suricata.git/commitdiff
detect: fix possible leak found by coverity
authorPhilippe Antoine <contact@catenacyber.fr>
Fri, 21 Jan 2022 15:31:54 +0000 (16:31 +0100)
committerVictor Julien <vjulien@oisf.net>
Fri, 21 Jan 2022 18:23:06 +0000 (19:23 +0100)
Conditions to create the leak are likely not reachable,
but this is still a bad pattern.

src/detect-engine-port.c

index 3adb0bbcda18697bcc25600a9b78845bc771b839..c1e1cec3ef3a1fe7cd9237bb61fca39e5d20d169 100644 (file)
@@ -213,8 +213,12 @@ int DetectPortInsert(DetectEngineCtx *de_ctx, DetectPort **head,
                     goto error;
 
                 r = DetectPortInsert(de_ctx, head, new);
-                if (r == -1)
+                if (r == -1) {
+                    if (c != NULL) {
+                        DetectPortFree(de_ctx, c);
+                    }
                     goto error;
+                }
 
                 if (c != NULL) {
                     SCLogDebug("inserting C (%p)", c);