]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
detect: add new_de_ctx release in case of errors in initialization 12001/head
authorZemeteri Kamimizu <zemeterisan@gmail.com>
Thu, 3 Oct 2024 10:05:55 +0000 (13:05 +0300)
committerJuliana Fajardini <jufajardini@gmail.com>
Mon, 21 Oct 2024 15:32:13 +0000 (08:32 -0700)
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
(cherry picked from commit adcac9ee0f8a20b68ca394ce0628063bc5c2ce7c)

src/detect-engine.c

index c86366314513a9155cf385bad371766a35f004de..9cfb222dd42139690d9ff4e478d9de319b5f8ba4 100644 (file)
@@ -3919,12 +3919,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, 0) < 0) {
         SCLogError("Loading signatures failed.");
-        goto error;
+        goto new_de_ctx_error;
     }
 
     DetectEngineAddToMaster(new_de_ctx);
@@ -3934,6 +3934,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;