From a5e08e7f791d77c8cf2bbeab6af260c34b2dcc7f Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Fri, 22 Jan 2016 06:41:49 +1030 Subject: [PATCH] lightning-cli: give error message when lightningd produces non-object response. Nicer than assert() failing without showing the response. Signed-off-by: Rusty Russell --- daemon/lightning-cli.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/daemon/lightning-cli.c b/daemon/lightning-cli.c index a43bc5964..6d35f0a5f 100644 --- a/daemon/lightning-cli.c +++ b/daemon/lightning-cli.c @@ -140,6 +140,10 @@ int main(int argc, char *argv[]) errx(ERROR_TALKING_TO_LIGHTNINGD, "Malformed response '%s'", resp); + if (toks->type != JSMN_OBJECT) + errx(ERROR_TALKING_TO_LIGHTNINGD, + "Non-object response '%s'", resp); + result = json_get_member(resp, toks, "result"); if (!result) errx(ERROR_TALKING_TO_LIGHTNINGD,