---
 info/map.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/info/map.c b/info/map.c
index 9d41e2a..628033c 100644
--- a/info/map.c
+++ b/info/map.c
@@ -206,6 +206,15 @@ print_totals (uint32_vector *entries, int64_t size)
   uint32_t type;
   bool comma = false;
 
+  /* This is necessary to avoid a divide by zero below, but if the
+   * size of the export is zero then we know we will not print any
+   * information below so return quickly.
+   */
+  if (size == 0) {
+    if (json_output) fprintf (fp, "[]\n");
+    return;
+  }
+
   if (json_output) fprintf (fp, "[\n");
 
   /* In the outer loop assume we have already printed all entries with
-- 
2.32.0

_______________________________________________
Libguestfs mailing list
[email protected]
https://listman.redhat.com/mailman/listinfo/libguestfs

Reply via email to