qga-win: fix leaks of build_guest_disk_info()

Introduced in commit b1ba8890e6, vol_h
handle should be closed, and "out" cleanup should be done after
DeviceIoControl() fails.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
This commit is contained in:
Marc-André Lureau 2018-11-03 17:01:43 +04:00 committed by Michael Roth
parent 160e5c22e5
commit f898ee0f99

View File

@ -797,7 +797,7 @@ static GuestDiskAddressList *build_guest_disk_info(char *guid, Error **errp)
0, extents, size, NULL, NULL)) {
error_setg_win32(errp, GetLastError(),
"failed to get disk extents");
return NULL;
goto out;
}
} else if (last_err == ERROR_INVALID_FUNCTION) {
/* Possibly CD-ROM or a shared drive. Try to pass the volume */
@ -855,6 +855,9 @@ static GuestDiskAddressList *build_guest_disk_info(char *guid, Error **errp)
out:
if (vol_h != INVALID_HANDLE_VALUE) {
CloseHandle(vol_h);
}
qapi_free_GuestDiskAddress(disk);
g_free(extents);
g_free(name);