vbox: Don't leak domain names in vboxListDefinedDomains

This commit is contained in:
Matthias Bolte 2010-12-16 23:33:14 +01:00
parent 8c572b6c78
commit 80d80fed9e

View File

@ -3112,13 +3112,17 @@ static int vboxListDefinedDomains(virConnectPtr conn, char ** const names, int m
|| (state > MachineState_LastOnline) ) {
machine->vtbl->GetName(machine, &machineNameUtf16);
VBOX_UTF16_TO_UTF8(machineNameUtf16, &machineName);
if (!(names[j++] = strdup(machineName))) {
names[j] = strdup(machineName);
VBOX_UTF16_FREE(machineNameUtf16);
VBOX_UTF8_FREE(machineName);
if (!names[j]) {
virReportOOMError();
for ( ; j >= 0 ; j--)
VIR_FREE(names[j]);
ret = -1;
goto cleanup;
}
j++;
ret++;
}
}
@ -3126,8 +3130,6 @@ static int vboxListDefinedDomains(virConnectPtr conn, char ** const names, int m
}
cleanup:
VBOX_UTF8_FREE(machineName);
VBOX_UTF16_FREE(machineNameUtf16);
vboxArrayRelease(&machines);
return ret;
}