From: Jose Bollo Date: Fri, 6 Jul 2018 13:07:08 +0000 (+0200) Subject: afb-cred: Fix memory leak X-Git-Tag: 5.99.2~25 X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?p=src%2Fapp-framework-binder.git;a=commitdiff_plain;h=7491c74e40512564bc361618a6f3d7e238b34dea afb-cred: Fix memory leak Change-Id: I1badca46d9e829c9b9443fce0a1e7d6a5ffad595 Signed-off-by: Jose Bollo --- 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); + } } }