summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJose Bollo <jose.bollo@iot.bzh>2018-07-06 15:07:08 +0200
committerJosé Bollo <jose.bollo@iot.bzh>2018-07-08 21:27:48 +0200
commit7491c74e40512564bc361618a6f3d7e238b34dea (patch)
tree4e69aea7d1e6d1396e7ff66498c52d6598aaac24
parent44b24775deb71c45c474ff97553a1514674bf2ad (diff)
afb-cred: Fix memory leak
Change-Id: I1badca46d9e829c9b9443fce0a1e7d6a5ffad595 Signed-off-by: Jose Bollo <jose.bollo@iot.bzh>
-rw-r--r--src/afb-cred.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/afb-cred.c b/src/afb-cred.c
index b7b3175e..a2cb577a 100644
--- a/src/afb-cred.c
+++ b/src/afb-cred.c
@@ -169,10 +169,12 @@ struct afb_cred *afb_cred_addref(struct afb_cred *cred)
void afb_cred_unref(struct afb_cred *cred)
{
if (cred && !__atomic_sub_fetch(&cred->refcount, 1, __ATOMIC_RELAXED)) {
- if (cred != current)
- free(cred);
- else
+ if (cred == current)
cred->refcount = 1;
+ else {
+ free((void*)cred->exported);
+ free(cred);
+ }
}
}