]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
reputation: Release memory on key add fails
authorJeff Lucovsky <jlucovsky@oisf.net>
Mon, 24 Apr 2023 13:51:56 +0000 (09:51 -0400)
committerVictor Julien <victor@inliniac.net>
Sun, 30 Jul 2023 12:22:52 +0000 (14:22 +0200)
Ensure that memory for the reputation key is released on failed adds.

Contributed by Giuseppe Longo <giuseppe@glongo.it>

Issue: 5748

src/reputation.c

index 57beefbe587881e83e20919164c8fe47e12e53eb..23080620c1c1c2de0e9ebd6ccf02b78e06f5d976 100644 (file)
@@ -100,6 +100,7 @@ static void SRepCIDRAddNetblock(SRepCIDRTree *cidr_ctx, char *ip, int cat, uint8
 
         SCLogDebug("adding ipv6 host %s", ip);
         if (SCRadixAddKeyIPV6String(ip, cidr_ctx->srepIPV6_tree[cat], (void *)user_data) == NULL) {
+            SCFree(user_data);
             SCLogWarning("failed to add ipv6 host %s", ip);
         }
 
@@ -115,6 +116,7 @@ static void SRepCIDRAddNetblock(SRepCIDRTree *cidr_ctx, char *ip, int cat, uint8
 
         SCLogDebug("adding ipv4 host %s", ip);
         if (SCRadixAddKeyIPV4String(ip, cidr_ctx->srepIPV4_tree[cat], (void *)user_data) == NULL) {
+            SCFree(user_data);
             SCLogWarning("failed to add ipv4 host %s", ip);
         }
     }