[libvirt PATCH v2 07/11] qemuMonitorGetBlockInfo: Use automatic memory management

Tim Wiederhake twiederh at redhat.com
Tue Jul 6 12:37:55 UTC 2021


Signed-off-by: Tim Wiederhake <twiederh at redhat.com>
---
 src/qemu/qemu_monitor.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
index 933d4a0154..2253c96cb5 100644
--- a/src/qemu/qemu_monitor.c
+++ b/src/qemu/qemu_monitor.c
@@ -2103,7 +2103,7 @@ qemuDomainDiskInfoFree(void *value)
 GHashTable *
 qemuMonitorGetBlockInfo(qemuMonitor *mon)
 {
-    GHashTable *table;
+    g_autoptr(GHashTable) table = NULL;
 
     QEMU_CHECK_MONITOR_NULL(mon);
 
@@ -2111,11 +2111,10 @@ qemuMonitorGetBlockInfo(qemuMonitor *mon)
         return NULL;
 
     if (qemuMonitorJSONGetBlockInfo(mon, table) < 0) {
-        virHashFree(table);
         return NULL;
     }
 
-    return table;
+    return g_steal_pointer(&table);
 }
 
 
-- 
2.31.1




More information about the libvir-list mailing list