reputation: Release memory on key add fails

Ensure that memory for the reputation key is released on failed adds.

Contributed by Giuseppe Longo <giuseppe@glongo.it>

Issue: 5748
pull/9337/head
Jeff Lucovsky 2 years ago committed by Victor Julien
parent ca0b2b4daa
commit c666317038

@ -100,6 +100,7 @@ static void SRepCIDRAddNetblock(SRepCIDRTree *cidr_ctx, char *ip, int cat, uint8
SCLogDebug("adding ipv6 host %s", ip); SCLogDebug("adding ipv6 host %s", ip);
if (SCRadixAddKeyIPV6String(ip, cidr_ctx->srepIPV6_tree[cat], (void *)user_data) == NULL) { if (SCRadixAddKeyIPV6String(ip, cidr_ctx->srepIPV6_tree[cat], (void *)user_data) == NULL) {
SCFree(user_data);
SCLogWarning("failed to add ipv6 host %s", ip); 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); SCLogDebug("adding ipv4 host %s", ip);
if (SCRadixAddKeyIPV4String(ip, cidr_ctx->srepIPV4_tree[cat], (void *)user_data) == NULL) { if (SCRadixAddKeyIPV4String(ip, cidr_ctx->srepIPV4_tree[cat], (void *)user_data) == NULL) {
SCFree(user_data);
SCLogWarning("failed to add ipv4 host %s", ip); SCLogWarning("failed to add ipv4 host %s", ip);
} }
} }

Loading…
Cancel
Save