]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virNWFilterCreateVarsFrom: Use automatic memory management
authorTim Wiederhake <twiederh@redhat.com>
Tue, 6 Jul 2021 08:20:38 +0000 (10:20 +0200)
committerTim Wiederhake <twiederh@redhat.com>
Fri, 23 Jul 2021 09:30:17 +0000 (11:30 +0200)
Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
src/nwfilter/nwfilter_gentech_driver.c

index 7014bdfc674dc9d176ffb30afac8de148ab6d9bf..29e5e0c86245095d9bd829201f24886105433c9b 100644 (file)
@@ -199,7 +199,7 @@ static GHashTable *
 virNWFilterCreateVarsFrom(GHashTable *vars1,
                           GHashTable *vars2)
 {
-    GHashTable *res = virHashNew(virNWFilterVarValueHashFree);
+    g_autoptr(GHashTable) res = virHashNew(virNWFilterVarValueHashFree);
 
     if (virNWFilterHashTablePutAll(vars1, res) < 0)
         goto error;
@@ -207,10 +207,9 @@ virNWFilterCreateVarsFrom(GHashTable *vars1,
     if (virNWFilterHashTablePutAll(vars2, res) < 0)
         goto error;
 
-    return res;
+    return g_steal_pointer(&res);
 
  error:
-    virHashFree(res);
     return NULL;
 }