* [PATCH lnf-ct] src: callback: fix memory leak when ct has dynamically allocated attr
@ 2013-07-03 10:52 Florian Westphal
2013-07-03 10:55 ` Pablo Neira Ayuso
0 siblings, 1 reply; 2+ messages in thread
From: Florian Westphal @ 2013-07-03 10:52 UTC (permalink / raw)
To: netfilter-devel; +Cc: Florian Westphal
Must free ct and exp using the _destroy functions, else we leak attributes with malloc'd data.
Signed-off-by: Florian Westphal <fw@strlen.de>
---
src/callback.c | 34 ++++++++--------------------------
1 files changed, 8 insertions(+), 26 deletions(-)
diff --git a/src/callback.c b/src/callback.c
index 684d3b2..19cc663 100644
--- a/src/callback.c
+++ b/src/callback.c
@@ -82,31 +82,13 @@ int __callback(struct nlmsghdr *nlh, struct nfattr *nfa[], void *data)
break;
}
- switch(ret) {
- case NFCT_CB_FAILURE:
- if (ct)
- free(ct);
- if (exp)
- free(exp);
- ret = NFNL_CB_FAILURE;
- break;
- case NFCT_CB_STOP:
- if (ct)
- free(ct);
- if (exp)
- free(exp);
- ret = NFNL_CB_STOP;
- break;
- case NFCT_CB_CONTINUE:
- if (ct)
- free(ct);
- if (exp)
- free(exp);
- ret = NFNL_CB_CONTINUE;
- break;
- case NFCT_CB_STOLEN:
- ret = NFNL_CB_CONTINUE;
- break;
- }
+ if (ret == NFCT_CB_STOLEN)
+ return NFNL_CB_CONTINUE;
+
+ if (ct)
+ nfct_destroy(ct);
+ if (exp)
+ nfexp_destroy(exp);
+
return ret;
}
--
1.7.8.6
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH lnf-ct] src: callback: fix memory leak when ct has dynamically allocated attr
2013-07-03 10:52 [PATCH lnf-ct] src: callback: fix memory leak when ct has dynamically allocated attr Florian Westphal
@ 2013-07-03 10:55 ` Pablo Neira Ayuso
0 siblings, 0 replies; 2+ messages in thread
From: Pablo Neira Ayuso @ 2013-07-03 10:55 UTC (permalink / raw)
To: Florian Westphal; +Cc: netfilter-devel
On Wed, Jul 03, 2013 at 12:52:41PM +0200, Florian Westphal wrote:
> Must free ct and exp using the _destroy functions, else we leak attributes with malloc'd data.
Looks good, push it please.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-07-03 10:56 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-07-03 10:52 [PATCH lnf-ct] src: callback: fix memory leak when ct has dynamically allocated attr Florian Westphal
2013-07-03 10:55 ` Pablo Neira Ayuso
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).