From 4d7dcf2007257bb972a8593563df6e82f356bf1c Mon Sep 17 00:00:00 2001 From: Jan-Piet Mens Date: Tue, 23 Feb 2016 17:29:52 +0100 Subject: [PATCH] check that friends db value is JSON array --- http.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/http.c b/http.c index 6cfd0d6..afeb963 100644 --- a/http.c +++ b/http.c @@ -408,6 +408,14 @@ JsonNode *populate_friends(struct mg_connection *conn, char *u, char *d) free(js); } + if (friends == NULL) { + return (results); + } + if (friends->tag != JSON_ARRAY) { + olog(LOG_ERR, "expecting value of friends:%s to be an array", UB(userdevice)); + return (results); + } + /* * Run through the array of friends of this user. Get LAST object, * which contains CARD and LOCATION data. Create an array of