From 0bf8cbaf1e4df06695381d6a0516a1b5c6635b79 Mon Sep 17 00:00:00 2001 From: Jan-Piet Mens Date: Wed, 24 Feb 2016 07:52:19 +0100 Subject: [PATCH] protect against missing tst in JSON --- listsort.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/listsort.c b/listsort.c index 4bf3cf9..9fea5de 100644 --- a/listsort.c +++ b/listsort.c @@ -35,6 +35,11 @@ static double cmp(JsonNode * a, JsonNode * b) JsonNode *tb = json_find_member(b, "tst"); //printf("a=%lf, b=%lf\n", ta->number_, tb->number_); + /* user may have chosen fields without tst */ + + if (!ta || !tb) + return (0.0); + return ta->number_ - tb->number_; }