]> Git Repo - qemu.git/commitdiff
qga-win: Fix build_guest_fsinfo() close of nonexistent
authorBasil Salman <[email protected]>
Mon, 12 Jul 2021 16:15:08 +0000 (11:15 -0500)
committerMichael Roth <[email protected]>
Tue, 3 Aug 2021 03:11:45 +0000 (22:11 -0500)
On the current error path of build_guest_fsinfo(), a non existent handle
is passed to CloseHandle().

This patch adds initialization of hLocalDiskHandle to
INVALID_HANDLE_VALUE, and checks for handle validity before the handle
is closed.

Signed-off-by: Basil Salman <[email protected]>
Signed-off-by: Basil Salman <[email protected]>
Signed-off-by: Michael Roth <[email protected]>
qga/commands-win32.c

index a099acb34d7f25b8c15e23df23e28b844b1786cd..763186efd40c65c5ea2577c9e699ab8bded40d5a 100644 (file)
@@ -1091,7 +1091,7 @@ static GuestFilesystemInfo *build_guest_fsinfo(char *guid, Error **errp)
     size_t len;
     uint64_t i64FreeBytesToCaller, i64TotalBytes, i64FreeBytes;
     GuestFilesystemInfo *fs = NULL;
-    HANDLE hLocalDiskHandle = NULL;
+    HANDLE hLocalDiskHandle = INVALID_HANDLE_VALUE;
 
     GetVolumePathNamesForVolumeName(guid, (LPCH)&mnt, 0, &info_size);
     if (GetLastError() != ERROR_MORE_DATA) {
@@ -1149,7 +1149,9 @@ static GuestFilesystemInfo *build_guest_fsinfo(char *guid, Error **errp)
     fs->type = g_strdup(fs_name);
     fs->disk = build_guest_disk_info(guid, errp);
 free:
-    CloseHandle(hLocalDiskHandle);
+    if (hLocalDiskHandle != INVALID_HANDLE_VALUE) {
+        CloseHandle(hLocalDiskHandle);
+    }
     g_free(mnt_point);
     return fs;
 }
This page took 0.028453 seconds and 4 git commands to generate.