d04bc02 secret: Fix memory leak in virSecretLoad

Authored and Committed by John Ferlan 6 years ago
    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.
    
        
file modified
+6 -8