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-6.0.12~33 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=79b89df331658e05fc950491622e37e1a4158525;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. (cherry picked from commit e8060990d17960dd97b6c81c813a6204d4d2bd46) --- diff --git a/src/detect-engine-port.c b/src/detect-engine-port.c index 59402ee214..e697000f21 100644 --- a/src/detect-engine-port.c +++ b/src/detect-engine-port.c @@ -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);