]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
util/thash: decrease memuse if array was allocated 11431/head
authorPhilippe Antoine <pantoine@oisf.net>
Thu, 4 Jul 2024 11:55:27 +0000 (13:55 +0200)
committerVictor Julien <victor@inliniac.net>
Thu, 4 Jul 2024 13:39:06 +0000 (15:39 +0200)
THashInitConfig may not allocate array and increase memuse.
Such a failure leads to THashShutdown which should not decrease
the memuse.

Ticket: 7135

src/util-thash.c

index 649d8b98b845ed936a1cfb0d8a5b0eabf8f34118..74c74e245a6980603a17336c96f1b80060b1248e 100644 (file)
@@ -378,8 +378,8 @@ void THashShutdown(THashTableContext *ctx)
         }
         SCFreeAligned(ctx->array);
         ctx->array = NULL;
+        (void)SC_ATOMIC_SUB(ctx->memuse, ctx->config.hash_size * sizeof(THashHashRow));
     }
-    (void) SC_ATOMIC_SUB(ctx->memuse, ctx->config.hash_size * sizeof(THashHashRow));
     THashDataQueueDestroy(&ctx->spare_q);
     DEBUG_VALIDATE_BUG_ON(SC_ATOMIC_GET(ctx->memuse) != 0);
     SCFree(ctx);