]> git.ipfire.org Git - thirdparty/mtr.git/commitdiff
json: Fix malformed json when the "hubs" list is empty 210/head
authorMatt Kimball <matt.kimball@gmail.com>
Wed, 12 Jul 2017 19:48:46 +0000 (12:48 -0700)
committerMatt Kimball <matt.kimball@gmail.com>
Wed, 12 Jul 2017 19:48:46 +0000 (12:48 -0700)
When generating JSON output, and when no hosts are found when
probing, the generated JSON was malformed.  (i.e. when the "hubs" list
in the generated JSON is empty, there was no closing bracket.)  This can
be reproduced by tracing to an unused host address on the local subnet.

This fixues issue #190.

ui/report.c

index 77003919631f38caf5c826e5bffff8337bcf2f8c..54f66696db7cc98dba9e4489d373b28b2298ac88 100644 (file)
@@ -364,11 +364,12 @@ void json_close(
             }
         }
         if (at + 1 == max) {
-            printf("    }]\n");
+            printf("    }");
         } else {
             printf("    },\n");
         }
     }
+    printf("]\n");
     printf("  }\n");
     printf("}\n");
 }