diff options
author | Basil Salman <basil@daynix.com> | 2021-07-12 11:15:08 -0500 |
---|---|---|
committer | Michael Roth <michael.roth@amd.com> | 2021-08-02 22:11:45 -0500 |
commit | 02ac3f4b959546ad69287aae84e2d52e21aeb479 (patch) | |
tree | dd20495e918bdfe98e8ae8680879491e467fdd3a /qga/commands-win32.c | |
parent | 3d98f9b68d2a8c10960d788027b8500ee947933f (diff) |
qga-win: Fix build_guest_fsinfo() close of nonexistent
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 <basil@daynix.com>
Signed-off-by: Basil Salman <basil@redhat.com>
Signed-off-by: Michael Roth <michael.roth@amd.com>
Diffstat (limited to 'qga/commands-win32.c')
-rw-r--r-- | qga/commands-win32.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/qga/commands-win32.c b/qga/commands-win32.c index a099acb34d..763186efd4 100644 --- a/qga/commands-win32.c +++ b/qga/commands-win32.c @@ -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; } |