]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virsh-snapshot: Don't leak @then in cmdSnapshotList()
authorMichal Privoznik <mprivozn@redhat.com>
Mon, 23 Aug 2021 12:08:10 +0000 (14:08 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Mon, 23 Aug 2021 12:52:15 +0000 (14:52 +0200)
The variable is used inside a loop in which it's allocated in
each iteration. Bring it inside the loop so that g_autoptr()
kicks in each iteration.

Fixes: 3caa28dc50df7ec215713075d669b20bef6473a2
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
tools/virsh-snapshot.c

index ee99d0e0611c4e6db60fbb3fce483911e84d3ad8..e08ecb691025b1ef27b88d4fd826e3f4ce8892fa 100644 (file)
@@ -1439,7 +1439,6 @@ cmdSnapshotList(vshControl *ctl, const vshCmd *cmd)
     size_t i;
     virDomainSnapshotPtr snapshot = NULL;
     long long creation_longlong;
-    g_autoptr(GDateTime) then = NULL;
     bool tree = vshCommandOptBool(cmd, "tree");
     bool name = vshCommandOptBool(cmd, "name");
     bool from = vshCommandOptBool(cmd, "from");
@@ -1533,6 +1532,7 @@ cmdSnapshotList(vshControl *ctl, const vshCmd *cmd)
     }
 
     for (i = 0; i < snaplist->nsnaps; i++) {
+        g_autoptr(GDateTime) then = NULL;
         g_autofree gchar *thenstr = NULL;
         g_autoptr(xmlDoc) xml = NULL;
         g_autoptr(xmlXPathContext) ctxt = NULL;