[libvirt PATCH 2/4] util: virIdentitySetCurrent: only unref the old identity on success

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 <jtomko@xxxxxxxxxx>
---
 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 e36e54ae4b..70843ecf9f 100644
--- a/src/util/viridentity.c
+++ b/src/util/viridentity.c
@@ -134,7 +134,7 @@ virIdentity *virIdentityGetCurrent(void)
  */
 int virIdentitySetCurrent(virIdentity *ident)
 {
-    g_autoptr(virIdentity) old = NULL;
+    virIdentity *old = NULL;
 
     if (virIdentityInitialize() < 0)
         return -1;
@@ -150,6 +150,8 @@ int virIdentitySetCurrent(virIdentity *ident)
         return -1;
     }
 
+    if (old)
+        g_object_unref(old);
     return 0;
 }
 
-- 
2.31.1




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux