diff --git a/lightningd/plugin_hook.c b/lightningd/plugin_hook.c index b6643e7d7..db033428e 100644 --- a/lightningd/plugin_hook.c +++ b/lightningd/plugin_hook.c @@ -157,19 +157,20 @@ static void plugin_hook_callback(const char *buffer, const jsmntok_t *toks, struct plugin_hook_call_link *last, *it; bool in_transaction = false; - log_debug(r->ld->log, "Plugin %s returned from %s hook call", - r->plugin->shortname, r->hook->name); + /* Pop the head off the call chain and continue with the next */ + last = list_pop(&r->call_chain, struct plugin_hook_call_link, list); + assert(last != NULL); + tal_del_destructor(last, plugin_hook_killed); + tal_free(last); if (r->ld->state == LD_STATE_SHUTDOWN) { log_debug(r->ld->log, "Abandoning plugin hook call due to shutdown"); return; } - /* Pop the head off the call chain and continue with the next */ - last = list_pop(&r->call_chain, struct plugin_hook_call_link, list); - assert(last != NULL); - tal_del_destructor(last, plugin_hook_killed); - tal_free(last); + + log_debug(r->ld->log, "Plugin %s returned from %s hook call", + r->plugin->shortname, r->hook->name); if (buffer) { resulttok = json_get_member(buffer, toks, "result");