]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
virsh-volume: Add missing check when calling virStreamNew
authorHongwei Bi <hwbi2008@gmail.com>
Sun, 29 Sep 2013 09:24:11 +0000 (17:24 +0800)
committerPeter Krempa <pkrempa@redhat.com>
Mon, 30 Sep 2013 13:00:07 +0000 (15:00 +0200)
Check return value of virStreamNew when called by cmdVolUpload and
cmdVolDownload.

tools/virsh-volume.c

index 7dab53245ac580359cdf76355cfe1acad8a983c9..0a66a6c7ac01693b3caf56e1261564b8ba5231da 100644 (file)
@@ -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;