mirror of https://gitee.com/openkylin/libvirt.git
vbox: Fix resource leak
Need to free the allocated hardDiskToOpen array. The contents of the array are just pointers returned by virVBoxSnapshotConfHardDiskByLocation and not allocated AFAICT so they don't need to also be freed as well. Found by Coverity Signed-off-by: John Ferlan <jferlan@redhat.com> Reviewed-by: Katerina Koukiou <kkoukiou@redhat.com>
This commit is contained in:
parent
da5b1a9188
commit
b8844727c9
|
@ -4627,6 +4627,8 @@ vboxSnapshotRedefine(virDomainPtr dom,
|
||||||
int realReadOnlyDisksPathSize = 0;
|
int realReadOnlyDisksPathSize = 0;
|
||||||
virVBoxSnapshotConfSnapshotPtr newSnapshotPtr = NULL;
|
virVBoxSnapshotConfSnapshotPtr newSnapshotPtr = NULL;
|
||||||
unsigned char snapshotUuid[VIR_UUID_BUFLEN];
|
unsigned char snapshotUuid[VIR_UUID_BUFLEN];
|
||||||
|
virVBoxSnapshotConfHardDiskPtr *hardDiskToOpen = NULL;
|
||||||
|
size_t hardDiskToOpenSize = 0;
|
||||||
char **searchResultTab = NULL;
|
char **searchResultTab = NULL;
|
||||||
ssize_t resultSize = 0;
|
ssize_t resultSize = 0;
|
||||||
int it = 0;
|
int it = 0;
|
||||||
|
@ -5080,8 +5082,6 @@ vboxSnapshotRedefine(virDomainPtr dom,
|
||||||
*/
|
*/
|
||||||
for (it = 0; it < def->dom->ndisks; it++) {
|
for (it = 0; it < def->dom->ndisks; it++) {
|
||||||
char *location = NULL;
|
char *location = NULL;
|
||||||
virVBoxSnapshotConfHardDiskPtr *hardDiskToOpen = NULL;
|
|
||||||
size_t hardDiskToOpenSize = 0;
|
|
||||||
|
|
||||||
location = def->dom->disks[it]->src->path;
|
location = def->dom->disks[it]->src->path;
|
||||||
if (!location)
|
if (!location)
|
||||||
|
@ -5394,8 +5394,7 @@ vboxSnapshotRedefine(virDomainPtr dom,
|
||||||
if (!location)
|
if (!location)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
virVBoxSnapshotConfHardDiskPtr *hardDiskToOpen = NULL;
|
hardDiskToOpenSize = virVBoxSnapshotConfDiskListToOpen(snapshotMachineDesc,
|
||||||
size_t hardDiskToOpenSize = virVBoxSnapshotConfDiskListToOpen(snapshotMachineDesc,
|
|
||||||
&hardDiskToOpen, location);
|
&hardDiskToOpen, location);
|
||||||
for (jt = 0; jt < hardDiskToOpenSize; jt++) {
|
for (jt = 0; jt < hardDiskToOpenSize; jt++) {
|
||||||
IMedium *medium = NULL;
|
IMedium *medium = NULL;
|
||||||
|
@ -5459,6 +5458,7 @@ vboxSnapshotRedefine(virDomainPtr dom,
|
||||||
virStringListFree(realReadOnlyDisksPath);
|
virStringListFree(realReadOnlyDisksPath);
|
||||||
virStringListFree(realReadWriteDisksPath);
|
virStringListFree(realReadWriteDisksPath);
|
||||||
virStringListFree(searchResultTab);
|
virStringListFree(searchResultTab);
|
||||||
|
VIR_FREE(hardDiskToOpen);
|
||||||
VIR_FREE(newSnapshotPtr);
|
VIR_FREE(newSnapshotPtr);
|
||||||
VIR_FREE(machineLocationPath);
|
VIR_FREE(machineLocationPath);
|
||||||
VIR_FREE(nameTmpUse);
|
VIR_FREE(nameTmpUse);
|
||||||
|
|
Loading…
Reference in New Issue