From 78d2ebc1bb982fc7615332d5cceb653fc8fd9383 Mon Sep 17 00:00:00 2001 From: Jan-Piet Mens Date: Sat, 29 Aug 2015 22:52:08 +0200 Subject: [PATCH] ocat: clean up --last --- ocat.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/ocat.c b/ocat.c index a28ba17..d3f8d8c 100644 --- a/ocat.c +++ b/ocat.c @@ -261,15 +261,17 @@ int main(int argc, char **argv) } if (last) { - JsonNode *obj; - char *js; + JsonNode *user_array; - obj = last_users(); - js = json_stringify(obj, " "); - printf("%s\n", js); + if ((user_array = last_users()) != NULL) { + char *js; - free(js); - json_delete(obj); + if ((js = json_stringify(user_array, " ")) != NULL) { + printf("%s\n", js); + free(js); + } + json_delete(user_array); + } return (0); }