From 6c16b95a384852de3da2b80bf15521385b550bba Mon Sep 17 00:00:00 2001 From: Andrew Bettison Date: Thu, 26 Jun 2014 14:53:59 +0930 Subject: [PATCH] Fix SEGV on empty /restful/meshms/.../conversationlist.json --- meshms_restful.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/meshms_restful.c b/meshms_restful.c index 2918e6c8..bffd57f0 100644 --- a/meshms_restful.c +++ b/meshms_restful.c @@ -206,7 +206,8 @@ static int restful_meshms_conversationlist_json(httpd_request *r, const char *re enum meshms_status status; if (meshms_failed(status = meshms_conversations_list(&r->sid1, NULL, &r->u.mclist.conv))) return http_request_meshms_response(r, 0, NULL, status); - meshms_conversation_iterator_start(&r->u.mclist.iter, r->u.mclist.conv); + if (r->u.mclist.conv != NULL) + meshms_conversation_iterator_start(&r->u.mclist.iter, r->u.mclist.conv); http_request_response_generated(&r->http, 200, CONTENT_TYPE_JSON, restful_meshms_conversationlist_json_content); return 1; } @@ -246,7 +247,7 @@ static int restful_meshms_conversationlist_json_content_chunk(struct http_reques r->u.mclist.phase = LIST_ROWS; return 1; case LIST_ROWS: - if (r->u.mclist.iter.current == NULL) { + if (r->u.mclist.conv == NULL || r->u.mclist.iter.current == NULL) { r->u.mclist.phase = LIST_END; // fall through... } else {