]> git.ipfire.org Git - thirdparty/libvirt.git/commit
secret: Fix memory leak in virSecretLoad
authorJohn Ferlan <jferlan@redhat.com>
Tue, 25 Jul 2017 13:02:09 +0000 (09:02 -0400)
committerJohn Ferlan <jferlan@redhat.com>
Tue, 25 Jul 2017 13:15:30 +0000 (09:15 -0400)
commitd04bc0278d25f41272318ba72f11011874472481
treeee179a8ee30e52273f204f998643823453f07616
parente4c0aff21514230f2f15aa5c7083219e1033f048
secret: Fix memory leak in virSecretLoad

If the virSecretLoadValue fails, the code jumped to cleanup without
setting @ret = obj, thus calling virSecretObjListRemove which only
accounts for the object reference related to adding the object to
the list during virSecretObjListAdd, but does not account for the
reference to the object itself as the return of @ret would be NULL
so the caller wouldn't call virSecretObjEndAPI on the object recently
added thus reducing the refcnt to zero.

This patch will perform the ObjListRemove in the failure path of
virSecretLoadValue and Unref @obj in order to perform clean up
and return @obj as NULL. The @def will be freed as part of the
virObjectUnref.
src/conf/virsecretobj.c