From e8060990d17960dd97b6c81c813a6204d4d2bd46 Mon Sep 17 00:00:00 2001 From: Philippe Antoine Date: Fri, 21 Jan 2022 16:31:54 +0100 Subject: [PATCH] detect: fix possible leak found by coverity Conditions to create the leak are likely not reachable, but this is still a bad pattern. --- src/detect-engine-port.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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); -- 2.47.2