From 41a52929f7ac6a2ad0cc771d477efbdf42b9d285 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Mon, 19 Sep 2022 10:19:52 +0930 Subject: [PATCH] libplugin: handle JSON reply after command freed. This can happen, and in fact does below in our test_autoclean_once test where we update the datastore, and return from the cmd. Signed-off-by: Rusty Russell --- plugins/libplugin.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/plugins/libplugin.c b/plugins/libplugin.c index ad2e59fbc..e5cacb531 100644 --- a/plugins/libplugin.c +++ b/plugins/libplugin.c @@ -681,10 +681,13 @@ static void handle_rpc_reply(struct plugin *plugin, const jsmntok_t *toks) out = strmap_getn(&plugin->out_reqs, plugin->rpc_buffer + idtok->start, idtok->end - idtok->start); - if (!out) - plugin_err(plugin, "JSON reply with unknown id '%.*s'", + if (!out) { + /* This can actually happen, if they free req! */ + plugin_log(plugin, LOG_DBG, "JSON reply with unknown id '%.*s'", json_tok_full_len(toks), json_tok_full(plugin->rpc_buffer, toks)); + return; + } /* Remove destructor if one existed */ if (out->cmd)