From 7584d992b8425fdf743f43e1e381df659fb4f11e Mon Sep 17 00:00:00 2001 From: Michal Privoznik Date: Wed, 3 Aug 2016 14:41:50 +0200 Subject: [PATCH] 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 --- tools/virsh.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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) {