]> git.ipfire.org Git - thirdparty/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>
Tue, 25 Apr 2023 13:19:47 +0000 (15:19 +0200)
Conditions to create the leak are likely not reachable,
but this is still a bad pattern.

(cherry picked from commit e8060990d17960dd97b6c81c813a6204d4d2bd46)

src/detect-engine-port.c

index 59402ee21491b3c61e07d8806e872f101f48dfe9..e697000f21fd436db72aea537003762608fa6954 100644 (file)
@@ -216,8 +216,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);