summaryrefslogtreecommitdiffstats
path: root/qga
diff options
context:
space:
mode:
authorKostiantyn Kostiuk2021-06-10 17:58:11 +0200
committerMichael Roth2021-08-03 05:11:45 +0200
commit24328b7a83a43d65389eda0cbabbd67595f43b5b (patch)
tree4ce1fff2a1e30ec9a434ace827c0e21a4ffab0fc /qga
parentqga-win: Fix handle leak in ga_get_win_product_name() (diff)
downloadqemu-24328b7a83a43d65389eda0cbabbd67595f43b5b.tar.gz
qemu-24328b7a83a43d65389eda0cbabbd67595f43b5b.tar.xz
qemu-24328b7a83a43d65389eda0cbabbd67595f43b5b.zip
qga-win: Free GMatchInfo properly
The g_regex_match function creates match_info even if it returns FALSE. So we should always call g_match_info_free. A better solution is using g_autoptr for match_info variable. Signed-off-by: Kostiantyn Kostiuk <konstantin@daynix.com> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> Signed-off-by: Michael Roth <michael.roth@amd.com>
Diffstat (limited to 'qga')
-rw-r--r--qga/commands-win32.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/qga/commands-win32.c b/qga/commands-win32.c
index 098211e724..7bac0c5d42 100644
--- a/qga/commands-win32.c
+++ b/qga/commands-win32.c
@@ -2459,7 +2459,7 @@ GuestDeviceInfoList *qmp_guest_get_devices(Error **errp)
continue;
}
for (j = 0; hw_ids[j] != NULL; j++) {
- GMatchInfo *match_info;
+ g_autoptr(GMatchInfo) match_info;
GuestDeviceIdPCI *id;
if (!g_regex_match(device_pci_re, hw_ids[j], 0, &match_info)) {
continue;
@@ -2476,7 +2476,6 @@ GuestDeviceInfoList *qmp_guest_get_devices(Error **errp)
id->vendor_id = g_ascii_strtoull(vendor_id, NULL, 16);
id->device_id = g_ascii_strtoull(device_id, NULL, 16);
- g_match_info_free(match_info);
break;
}
if (skip) {