]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
detect: add new_de_ctx release in case of errors in initialization
authorZemeteri Kamimizu <zemeterisan@gmail.com>
Thu, 3 Oct 2024 10:05:55 +0000 (13:05 +0300)
committerVictor Julien <victor@inliniac.net>
Tue, 8 Oct 2024 11:02:47 +0000 (13:02 +0200)
Detect engine tenant reloading function hasn't got engine release call
under error label, so it is possible memory leak in case of errors in
further new detect engine initialization.

Bug: #7303

src/detect-engine.c

index 58b5c9967c8bbef2695decd077630d819b0e57ac..be2f5b462abad5944f48078e515d63bc845db58f 100644 (file)
@@ -3931,12 +3931,12 @@ static int DetectEngineMultiTenantReloadTenant(uint32_t tenant_id, const char *f
     new_de_ctx->tenant_path = SCStrdup(filename);
     if (new_de_ctx->tenant_path == NULL) {
         SCLogError("Failed to duplicate path");
-        goto error;
+        goto new_de_ctx_error;
     }
 
     if (SigLoadSignatures(new_de_ctx, NULL, false) < 0) {
         SCLogError("Loading signatures failed.");
-        goto error;
+        goto new_de_ctx_error;
     }
 
     DetectEngineAddToMaster(new_de_ctx);
@@ -3946,6 +3946,9 @@ static int DetectEngineMultiTenantReloadTenant(uint32_t tenant_id, const char *f
     DetectEngineDeReference(&old_de_ctx);
     return 0;
 
+new_de_ctx_error:
+    DetectEngineCtxFree(new_de_ctx);
+
 error:
     DetectEngineDeReference(&old_de_ctx);
     return -1;