From: Hongwei Bi Date: Sun, 29 Sep 2013 09:24:11 +0000 (+0800) Subject: virsh-volume: Add missing check when calling virStreamNew X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=0c500a4f2e3b288afbbcad299aa19dbe5b51add7;p=libvirt.git virsh-volume: Add missing check when calling virStreamNew Check return value of virStreamNew when called by cmdVolUpload and cmdVolDownload. --- diff --git a/tools/virsh-volume.c b/tools/virsh-volume.c index 7dab53245a..0a66a6c7ac 100644 --- a/tools/virsh-volume.c +++ b/tools/virsh-volume.c @@ -665,7 +665,11 @@ cmdVolUpload(vshControl *ctl, const vshCmd *cmd) goto cleanup; } - st = virStreamNew(ctl->conn, 0); + if (!(st = virStreamNew(ctl->conn, 0))) { + vshError(ctl, _("cannot create a new stream")); + goto cleanup; + } + if (virStorageVolUpload(vol, st, offset, length, 0) < 0) { vshError(ctl, _("cannot upload to volume %s"), name); goto cleanup; @@ -775,7 +779,11 @@ cmdVolDownload(vshControl *ctl, const vshCmd *cmd) created = true; } - st = virStreamNew(ctl->conn, 0); + if (!(st = virStreamNew(ctl->conn, 0))) { + vshError(ctl, _("cannot create a new stream")); + goto cleanup; + } + if (virStorageVolDownload(vol, st, offset, length, 0) < 0) { vshError(ctl, _("cannot download from volume %s"), name); goto cleanup;