From: Matt Kimball Date: Wed, 12 Jul 2017 19:48:46 +0000 (-0700) Subject: json: Fix malformed json when the "hubs" list is empty X-Git-Tag: v0.93~46^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F210%2Fhead;p=thirdparty%2Fmtr.git json: Fix malformed json when the "hubs" list is empty 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. --- diff --git a/ui/report.c b/ui/report.c index 7700391..54f6669 100644 --- a/ui/report.c +++ b/ui/report.c @@ -364,11 +364,12 @@ void json_close( } } if (at + 1 == max) { - printf(" }]\n"); + printf(" }"); } else { printf(" },\n"); } } + printf("]\n"); printf(" }\n"); printf("}\n"); }