virstorageobj: Don't clear vols if they weren't initialized

If virStoragePoolObjNew() fails to create new volume object list
then virObjectUnref() is called and since refcounter is 1 then
virStoragePoolObjDispose() is called which in turn calls
virStoragePoolObjClearVols() which in turn dereferences
obj->volumes.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
This commit is contained in:
Michal Privoznik 2019-05-14 10:31:52 +02:00
parent e34c028af1
commit 0cf3bb805c

View File

@ -619,6 +619,9 @@ virStoragePoolSourceFindDuplicateDevices(virStoragePoolObjPtr obj,
void void
virStoragePoolObjClearVols(virStoragePoolObjPtr obj) virStoragePoolObjClearVols(virStoragePoolObjPtr obj)
{ {
if (!obj->volumes)
return;
virHashRemoveAll(obj->volumes->objsKey); virHashRemoveAll(obj->volumes->objsKey);
virHashRemoveAll(obj->volumes->objsName); virHashRemoveAll(obj->volumes->objsName);
virHashRemoveAll(obj->volumes->objsPath); virHashRemoveAll(obj->volumes->objsPath);