]> Git Repo - qemu.git/commitdiff
qga-win: Free GMatchInfo properly
authorKostiantyn Kostiuk <[email protected]>
Thu, 10 Jun 2021 15:58:11 +0000 (18:58 +0300)
committerMichael Roth <[email protected]>
Tue, 3 Aug 2021 03:11:45 +0000 (22:11 -0500)
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 <[email protected]>
Reviewed-by: Daniel P. BerrangĂ© <[email protected]>
Reviewed-by: Philippe Mathieu-DaudĂ© <[email protected]>
Signed-off-by: Michael Roth <[email protected]>
qga/commands-win32.c

index 098211e72464efe8ac21857b6de0c990544d4b26..7bac0c5d42273e605c16b935b499cc673d6bd9e9 100644 (file)
@@ -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) {
This page took 0.029051 seconds and 4 git commands to generate.