mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-25 14:05:18 +00:00
util: virIdentitySetCurrent: only unref the old identity on success
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@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
09b08e9a80
commit
a082c46229
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user