mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
vbox: Resolve Coverity RESOURCE_LEAK
If the virStringSearch() returns a 0 (zero), then each of the uses of the call will just jump to cleanup forgetting to free the returned empty list. Expand the scope a bit of each use and free at cleanup.
This commit is contained in:
parent
11b9167954
commit
74aab575c4
@ -4463,6 +4463,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];
|
||||||
|
char **searchResultTab = NULL;
|
||||||
|
ssize_t resultSize = 0;
|
||||||
int it = 0;
|
int it = 0;
|
||||||
int jt = 0;
|
int jt = 0;
|
||||||
PRUint32 aMediaSize = 0;
|
PRUint32 aMediaSize = 0;
|
||||||
@ -4862,8 +4864,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;
|
||||||
const char *uuidReplacing = NULL;
|
const char *uuidReplacing = NULL;
|
||||||
char **searchResultTab = NULL;
|
|
||||||
ssize_t resultSize = 0;
|
|
||||||
char *tmp = NULL;
|
char *tmp = NULL;
|
||||||
|
|
||||||
location = def->dom->disks[it]->src->path;
|
location = def->dom->disks[it]->src->path;
|
||||||
@ -4885,6 +4885,7 @@ vboxSnapshotRedefine(virDomainPtr dom,
|
|||||||
searchResultTab[it],
|
searchResultTab[it],
|
||||||
uuidReplacing);
|
uuidReplacing);
|
||||||
virStringFreeList(searchResultTab);
|
virStringFreeList(searchResultTab);
|
||||||
|
searchResultTab = NULL;
|
||||||
VIR_FREE(newSnapshotPtr->storageController);
|
VIR_FREE(newSnapshotPtr->storageController);
|
||||||
if (!tmp)
|
if (!tmp)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -5029,8 +5030,6 @@ vboxSnapshotRedefine(virDomainPtr dom,
|
|||||||
|
|
||||||
if (needToChangeStorageController) {
|
if (needToChangeStorageController) {
|
||||||
/*We need to append this disk in the storage controller*/
|
/*We need to append this disk in the storage controller*/
|
||||||
char **searchResultTab = NULL;
|
|
||||||
ssize_t resultSize = 0;
|
|
||||||
char *tmp = NULL;
|
char *tmp = NULL;
|
||||||
resultSize = virStringSearch(snapshotMachineDesc->storageController,
|
resultSize = virStringSearch(snapshotMachineDesc->storageController,
|
||||||
VBOX_UUID_REGEX,
|
VBOX_UUID_REGEX,
|
||||||
@ -5045,7 +5044,6 @@ vboxSnapshotRedefine(virDomainPtr dom,
|
|||||||
tmp = virStringReplace(snapshotMachineDesc->storageController,
|
tmp = virStringReplace(snapshotMachineDesc->storageController,
|
||||||
searchResultTab[it],
|
searchResultTab[it],
|
||||||
disk->uuid);
|
disk->uuid);
|
||||||
virStringFreeList(searchResultTab);
|
|
||||||
VIR_FREE(snapshotMachineDesc->storageController);
|
VIR_FREE(snapshotMachineDesc->storageController);
|
||||||
if (!tmp)
|
if (!tmp)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -5077,8 +5075,6 @@ vboxSnapshotRedefine(virDomainPtr dom,
|
|||||||
virVBoxSnapshotConfHardDiskPtr disk = NULL;
|
virVBoxSnapshotConfHardDiskPtr disk = NULL;
|
||||||
char *uuid = NULL;
|
char *uuid = NULL;
|
||||||
char *format = NULL;
|
char *format = NULL;
|
||||||
char **searchResultTab = NULL;
|
|
||||||
ssize_t resultSize = 0;
|
|
||||||
char *tmp = NULL;
|
char *tmp = NULL;
|
||||||
vboxIIDUnion iid, parentiid;
|
vboxIIDUnion iid, parentiid;
|
||||||
|
|
||||||
@ -5189,7 +5185,6 @@ vboxSnapshotRedefine(virDomainPtr dom,
|
|||||||
tmp = virStringReplace(snapshotMachineDesc->storageController,
|
tmp = virStringReplace(snapshotMachineDesc->storageController,
|
||||||
searchResultTab[it],
|
searchResultTab[it],
|
||||||
disk->uuid);
|
disk->uuid);
|
||||||
virStringFreeList(searchResultTab);
|
|
||||||
VIR_FREE(snapshotMachineDesc->storageController);
|
VIR_FREE(snapshotMachineDesc->storageController);
|
||||||
if (!tmp)
|
if (!tmp)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -5299,6 +5294,7 @@ vboxSnapshotRedefine(virDomainPtr dom,
|
|||||||
VBOX_UTF8_FREE(machineName);
|
VBOX_UTF8_FREE(machineName);
|
||||||
virStringFreeList(realReadOnlyDisksPath);
|
virStringFreeList(realReadOnlyDisksPath);
|
||||||
virStringFreeList(realReadWriteDisksPath);
|
virStringFreeList(realReadWriteDisksPath);
|
||||||
|
virStringFreeList(searchResultTab);
|
||||||
VIR_FREE(newSnapshotPtr);
|
VIR_FREE(newSnapshotPtr);
|
||||||
VIR_FREE(machineLocationPath);
|
VIR_FREE(machineLocationPath);
|
||||||
VIR_FREE(nameTmpUse);
|
VIR_FREE(nameTmpUse);
|
||||||
@ -6730,6 +6726,8 @@ vboxDomainSnapshotDeleteMetadataOnly(virDomainSnapshotPtr snapshot)
|
|||||||
char *settingsFilepath = NULL;
|
char *settingsFilepath = NULL;
|
||||||
virVBoxSnapshotConfMachinePtr snapshotMachineDesc = NULL;
|
virVBoxSnapshotConfMachinePtr snapshotMachineDesc = NULL;
|
||||||
int isCurrent = -1;
|
int isCurrent = -1;
|
||||||
|
char **searchResultTab = NULL;
|
||||||
|
ssize_t resultSize = 0;
|
||||||
int it = 0;
|
int it = 0;
|
||||||
PRUnichar *machineNameUtf16 = NULL;
|
PRUnichar *machineNameUtf16 = NULL;
|
||||||
char *machineName = NULL;
|
char *machineName = NULL;
|
||||||
@ -6822,8 +6820,6 @@ vboxDomainSnapshotDeleteMetadataOnly(virDomainSnapshotPtr snapshot)
|
|||||||
virVBoxSnapshotConfHardDiskPtr disk = NULL;
|
virVBoxSnapshotConfHardDiskPtr disk = NULL;
|
||||||
char *uuid = NULL;
|
char *uuid = NULL;
|
||||||
char *format = NULL;
|
char *format = NULL;
|
||||||
char **searchResultTab = NULL;
|
|
||||||
ssize_t resultSize = 0;
|
|
||||||
char *tmp = NULL;
|
char *tmp = NULL;
|
||||||
vboxIIDUnion iid, parentiid;
|
vboxIIDUnion iid, parentiid;
|
||||||
resultCodeUnion resultCode;
|
resultCodeUnion resultCode;
|
||||||
@ -6950,7 +6946,6 @@ vboxDomainSnapshotDeleteMetadataOnly(virDomainSnapshotPtr snapshot)
|
|||||||
tmp = virStringReplace(snapshotMachineDesc->storageController,
|
tmp = virStringReplace(snapshotMachineDesc->storageController,
|
||||||
searchResultTab[it],
|
searchResultTab[it],
|
||||||
disk->uuid);
|
disk->uuid);
|
||||||
virStringFreeList(searchResultTab);
|
|
||||||
VIR_FREE(snapshotMachineDesc->storageController);
|
VIR_FREE(snapshotMachineDesc->storageController);
|
||||||
if (!tmp)
|
if (!tmp)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -6970,8 +6965,6 @@ vboxDomainSnapshotDeleteMetadataOnly(virDomainSnapshotPtr snapshot)
|
|||||||
} else {
|
} else {
|
||||||
for (it = 0; it < def->dom->ndisks; it++) {
|
for (it = 0; it < def->dom->ndisks; it++) {
|
||||||
const char *uuidRO = NULL;
|
const char *uuidRO = NULL;
|
||||||
char **searchResultTab = NULL;
|
|
||||||
ssize_t resultSize = 0;
|
|
||||||
char *tmp = NULL;
|
char *tmp = NULL;
|
||||||
uuidRO = virVBoxSnapshotConfHardDiskUuidByLocation(snapshotMachineDesc,
|
uuidRO = virVBoxSnapshotConfHardDiskUuidByLocation(snapshotMachineDesc,
|
||||||
def->dom->disks[it]->src->path);
|
def->dom->disks[it]->src->path);
|
||||||
@ -6996,7 +6989,6 @@ vboxDomainSnapshotDeleteMetadataOnly(virDomainSnapshotPtr snapshot)
|
|||||||
tmp = virStringReplace(snapshotMachineDesc->storageController,
|
tmp = virStringReplace(snapshotMachineDesc->storageController,
|
||||||
searchResultTab[it],
|
searchResultTab[it],
|
||||||
uuidRO);
|
uuidRO);
|
||||||
virStringFreeList(searchResultTab);
|
|
||||||
VIR_FREE(snapshotMachineDesc->storageController);
|
VIR_FREE(snapshotMachineDesc->storageController);
|
||||||
if (!tmp)
|
if (!tmp)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -7147,6 +7139,7 @@ vboxDomainSnapshotDeleteMetadataOnly(virDomainSnapshotPtr snapshot)
|
|||||||
VBOX_RELEASE(machine);
|
VBOX_RELEASE(machine);
|
||||||
VBOX_UTF16_FREE(settingsFilePathUtf16);
|
VBOX_UTF16_FREE(settingsFilePathUtf16);
|
||||||
VBOX_UTF8_FREE(settingsFilepath);
|
VBOX_UTF8_FREE(settingsFilepath);
|
||||||
|
virStringFreeList(searchResultTab);
|
||||||
VIR_FREE(snapshotMachineDesc);
|
VIR_FREE(snapshotMachineDesc);
|
||||||
VBOX_UTF16_FREE(machineNameUtf16);
|
VBOX_UTF16_FREE(machineNameUtf16);
|
||||||
VBOX_UTF8_FREE(machineName);
|
VBOX_UTF8_FREE(machineName);
|
||||||
|
Loading…
Reference in New Issue
Block a user