From c666317038d9ced0df39cb5d783d87e687c3248a Mon Sep 17 00:00:00 2001 From: Jeff Lucovsky Date: Mon, 24 Apr 2023 09:51:56 -0400 Subject: [PATCH] reputation: Release memory on key add fails Ensure that memory for the reputation key is released on failed adds. Contributed by Giuseppe Longo Issue: 5748 --- src/reputation.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/reputation.c b/src/reputation.c index 57beefbe58..23080620c1 100644 --- a/src/reputation.c +++ b/src/reputation.c @@ -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); } }