virsh: Do not try to free domain if it is NULL

Without these patch, there will be error like below if domain
is NULL.

error: invalid domain pointer in virDomainFree

Which is useless.
This commit is contained in:
Osier Yang 2011-08-23 21:42:22 +08:00
parent 0756e5ad92
commit 241cbc13ac

View File

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