]> xenbits.xensource.com Git - libvirt.git/commitdiff
virsh: Do not try to free domain if it is NULL
authorOsier Yang <jyang@redhat.com>
Tue, 23 Aug 2011 13:42:22 +0000 (21:42 +0800)
committerOsier Yang <jyang@redhat.com>
Tue, 23 Aug 2011 13:42:22 +0000 (21:42 +0800)
Without these patch, there will be error like below if domain
is NULL.

error: invalid domain pointer in virDomainFree

Which is useless.

tools/virsh.c

index 004fe80ffb5b3cd688e85064d0dab464139cd26a..0bb4c679d63f407281fcf0e012275f8351d2fbbb 100644 (file)
@@ -5201,17 +5201,17 @@ blockJobImpl(vshControl *ctl, const vshCmd *cmd,
     int ret = -1;
 
     if (!vshConnectionUsability(ctl, ctl->conn))
-        goto out;
+        goto cleanup;
 
     if (!(dom = vshCommandOptDomain(ctl, cmd, &name)))
-        goto out;
+        goto cleanup;
 
     if (vshCommandOptString(cmd, "path", &path) < 0)
-        goto out;
+        goto cleanup;
 
     if (vshCommandOptUL(cmd, "bandwidth", &bandwidth) < 0) {
         vshError(ctl, "%s", _("bandwidth must be a number"));
-        goto out;
+        goto cleanup;
     }
 
     if (mode == VSH_CMD_BLOCK_JOB_ABORT)
@@ -5224,7 +5224,8 @@ blockJobImpl(vshControl *ctl, const vshCmd *cmd,
         ret = virDomainBlockPull(dom, path, bandwidth, 0);
 
 out:
-    virDomainFree(dom);
+    if (dom)
+        virDomainFree(dom);
     return ret;
 }