]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virsh-domain: Add a missing check and fix leak in cmdScreenshot
authorHongwei Bi <hwbi2008@gmail.com>
Wed, 25 Sep 2013 14:54:24 +0000 (22:54 +0800)
committerEric Blake <eblake@redhat.com>
Wed, 25 Sep 2013 15:34:24 +0000 (09:34 -0600)
Signed-off-by: Eric Blake <eblake@redhat.com>
tools/virsh-domain.c

index 856e8885b47467bc398dd8d1e873b305da7c71dc..be7fcc8b35fe1ecd3fa35e370e6d0c96bc98b00a 100644 (file)
@@ -4610,7 +4610,8 @@ cmdScreenshot(vshControl *ctl, const vshCmd *cmd)
     if (!(dom = vshCommandOptDomain(ctl, cmd, &name)))
         return false;
 
-    st = virStreamNew(ctl->conn, 0);
+    if (!(st = virStreamNew(ctl->conn, 0)))
+        goto cleanup;
 
     mime = virDomainScreenshot(dom, st, screen, flags);
     if (!mime) {
@@ -4619,8 +4620,8 @@ cmdScreenshot(vshControl *ctl, const vshCmd *cmd)
     }
 
     if (!file) {
-        if (!(file=vshGenFileName(ctl, dom, mime)))
-            return false;
+        if (!(file = vshGenFileName(ctl, dom, mime)))
+            goto cleanup;
         generated = true;
     }