From 8a06893a603f32791899314fd16afdd424e77e6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A1n=20Tomko?= Date: Fri, 3 Sep 2021 16:04:44 +0200 Subject: [PATCH 100/108] util: virIdentitySetCurrent: only unref the old identity on success MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In the unlikely case that we were unable to set the new identity, we would unref the old one even though it still could be in the thread-local storage. Fixes: c6825d88137cb8e4debdf4310e45ee23cb5698c0 Signed-off-by: Ján Tomko Reviewed-by: Michal Privoznik (cherry picked from commit a082c462290bfa8fd4cbbc41c1d6040864228c78) --- src/util/viridentity.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/util/viridentity.c b/src/util/viridentity.c index 2cb9042a84..e133d29e7d 100644 --- a/src/util/viridentity.c +++ b/src/util/viridentity.c @@ -122,7 +122,7 @@ virIdentityPtr virIdentityGetCurrent(void) */ int virIdentitySetCurrent(virIdentityPtr ident) { - g_autoptr(virIdentity) old = NULL; + virIdentity *old = NULL; if (virIdentityInitialize() < 0) return -1; @@ -138,6 +138,8 @@ int virIdentitySetCurrent(virIdentityPtr ident) return -1; } + if (old) + g_object_unref(old); return 0; } -- 2.33.0