lightningd: if a plugin gives a JSON-RPC error, print it.

We currently just segfault when the deserialize function to access resulttok.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2019-04-16 09:40:07 +09:30 committed by Christian Decker
parent a9e71d76b5
commit d3c312860d
1 changed files with 8 additions and 1 deletions

View File

@ -53,7 +53,14 @@ static void plugin_hook_callback(const char *buffer, const jsmntok_t *toks,
struct plugin_hook_request *r)
{
const jsmntok_t *resulttok = json_get_member(buffer, toks, "result");
void *response = r->hook->deserialize_response(r, buffer, resulttok);
void *response;
if (!resulttok)
fatal("Plugin for %s returned non-result response %.*s",
r->hook->name,
toks->end - toks->start, buffer + toks->end);
response = r->hook->deserialize_response(r, buffer, resulttok);
db_begin_transaction(r->db);
r->hook->response_cb(r->cb_arg, response);
db_commit_transaction(r->db);