mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-11 07:17:44 +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: c6825d8813
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)
|
int virIdentitySetCurrent(virIdentity *ident)
|
||||||
{
|
{
|
||||||
g_autoptr(virIdentity) old = NULL;
|
virIdentity *old = NULL;
|
||||||
|
|
||||||
if (virIdentityInitialize() < 0)
|
if (virIdentityInitialize() < 0)
|
||||||
return -1;
|
return -1;
|
||||||
@ -150,6 +150,8 @@ int virIdentitySetCurrent(virIdentity *ident)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (old)
|
||||||
|
g_object_unref(old);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user