From: Michal Privoznik Date: Wed, 3 Aug 2016 12:41:50 +0000 (+0200) Subject: virshConnect: Don't leak polkit agent X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=7584d992b8425fdf743f43e1e381df659fb4f11e;p=libvirt.git virshConnect: Don't leak polkit agent In our attempts to reconnect, we may create a polkit daemon. However, it may happen that we would rewrite the variable that already holds pointer to the agent. Signed-off-by: Michal Privoznik --- diff --git a/tools/virsh.c b/tools/virsh.c index d3fe06f190..cb60edcfc9 100644 --- a/tools/virsh.c +++ b/tools/virsh.c @@ -168,7 +168,7 @@ virshConnect(vshControl *ctl, const char *uri, bool readonly) err = virGetLastError(); if (err && err->domain == VIR_FROM_POLKIT && err->code == VIR_ERR_AUTH_UNAVAILABLE) { - if (!(pkagent = virPolkitAgentCreate())) + if (!pkagent && !(pkagent = virPolkitAgentCreate())) goto cleanup; } else if (err && err->domain == VIR_FROM_POLKIT && err->code == VIR_ERR_AUTH_FAILED) {