]> xenbits.xensource.com Git - libvirt.git/commitdiff
virshConnect: Don't leak polkit agent
authorMichal Privoznik <mprivozn@redhat.com>
Wed, 3 Aug 2016 12:41:50 +0000 (14:41 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Thu, 4 Aug 2016 13:32:21 +0000 (15:32 +0200)
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 <mprivozn@redhat.com>
tools/virsh.c

index d3fe06f190324a0b8044dc88990e5b9900307590..cb60edcfc9dfdadf0f9edb462617ed1a2a7c22a4 100644 (file)
@@ -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) {