From: John Ferlan Date: Tue, 15 Jan 2013 18:12:57 +0000 (-0500) Subject: tools: Check return status on virBufferTrim() X-Git-Tag: v1.0.2-rc1~138 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e69a85cc2b70c13142b176177290e61c5df18df1;p=thirdparty%2Flibvirt.git tools: Check return status on virBufferTrim() --- diff --git a/tools/virsh.c b/tools/virsh.c index eadc519451..669c9c9c98 100644 --- a/tools/virsh.c +++ b/tools/virsh.c @@ -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;