]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
tools: Check return status on virBufferTrim()
authorJohn Ferlan <jferlan@redhat.com>
Tue, 15 Jan 2013 18:12:57 +0000 (13:12 -0500)
committerMartin Kletzander <mkletzan@redhat.com>
Wed, 16 Jan 2013 09:43:13 +0000 (10:43 +0100)
tools/virsh.c

index eadc519451301c84e73d837889adb01dbb2ed693..669c9c9c987ac493b5329f37fe42a3a0e3f2aa1d 100644 (file)
@@ -536,6 +536,8 @@ vshTreePrintInternal(vshControl *ctl,
 
     /* Finally print all children */
     virBufferAddLit(indent, "  ");
+    if (virBufferError(indent))
+        goto cleanup;
     for (i = 0 ; i < num_devices ; i++) {
         const char *parent = (lookup)(i, true, opaque);
 
@@ -545,15 +547,18 @@ vshTreePrintInternal(vshControl *ctl,
                                  false, indent) < 0)
             goto cleanup;
     }
-    virBufferTrim(indent, "  ", -1);
+    if (virBufferTrim(indent, "  ", -1) < 0)
+        goto cleanup;
 
     /* If there was no child device, and we're the last in
      * a list of devices, then print another blank line */
     if (nextlastdev == -1 && devid == lastdev)
         vshPrint(ctl, "%s\n", virBufferCurrentContent(indent));
 
-    if (!root)
-        virBufferTrim(indent, NULL, 2);
+    if (!root) {
+        if (virBufferTrim(indent, NULL, 2) < 0)
+            goto cleanup;
+    }
     ret = 0;
 cleanup:
     return ret;