bus: unref buscreds on failure

Actually unref the buscreds when we are not going to return a
pointer to them. As when bus_creds_add_more fails we immediately
return the error code otherwise and leak the new buscreds.
Found with coverity. Fixes: CID#1237761
This commit is contained in:
Philippe De Swert
2014-09-11 17:29:19 +02:00
committed by David Herrmann
parent b67ddc7bbe
commit 2b347169b9
+3 -1
View File
@@ -3339,8 +3339,10 @@ _public_ int sd_bus_get_peer_creds(sd_bus *bus, uint64_t mask, sd_bus_creds **re
}
r = bus_creds_add_more(c, mask, pid, 0);
if (r < 0)
if (r < 0) {
sd_bus_creds_unref(c);
return r;
}
*ret = c;
return 0;