From: Philippe Antoine Date: Fri, 21 Jan 2022 15:31:54 +0000 (+0100) Subject: detect: fix possible leak found by coverity X-Git-Tag: suricata-7.0.0-beta1~995 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e8060990d17960dd97b6c81c813a6204d4d2bd46;p=thirdparty%2Fsuricata.git detect: fix possible leak found by coverity Conditions to create the leak are likely not reachable, but this is still a bad pattern. --- diff --git a/src/detect-engine-port.c b/src/detect-engine-port.c index 3adb0bbcda..c1e1cec3ef 100644 --- a/src/detect-engine-port.c +++ b/src/detect-engine-port.c @@ -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);