From 56d5bb4c6346654291be68fb3089d43cfcc9dd22 Mon Sep 17 00:00:00 2001 From: Cy Schubert Date: Fri, 3 Mar 2017 21:32:27 +0000 Subject: [PATCH] Fix leak (free str before returning when ctx's calloc fails). Submitted by: trix_juniper.net (Tom Rix) Discovered by: clang's static analyzer MFC after: 4 days Relnotes: ngie Differential Revision: D9877 --- contrib/ipfilter/lib/save_v2trap.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/contrib/ipfilter/lib/save_v2trap.c b/contrib/ipfilter/lib/save_v2trap.c index 78e76f6646fa..0507be9f2696 100644 --- a/contrib/ipfilter/lib/save_v2trap.c +++ b/contrib/ipfilter/lib/save_v2trap.c @@ -124,8 +124,10 @@ snmpv2_parse(char **strings) str = strdup(*strings); ctx = calloc(1, sizeof(*ctx)); - if (ctx == NULL) + if (ctx == NULL) { + free(str); return NULL; + } ctx->fd = -1;