plugin: autoclean fix double free when re-enable, remove xfail mark from test_

Fixes a crash when enabling after a disable with cycle_seconds=0.
This commit is contained in:
Simon Vrouwe 2022-07-14 12:40:11 +03:00 committed by Rusty Russell
parent cc40243399
commit ad3cbed7c2
2 changed files with 3 additions and 2 deletions

View file

@ -48,12 +48,14 @@ static struct command_result *json_autocleaninvoice(struct command *cmd,
cycle_seconds = *cycle; cycle_seconds = *cycle;
expired_by = *exby; expired_by = *exby;
cleantimer = tal_free(cleantimer);
if (cycle_seconds == 0) { if (cycle_seconds == 0) {
response = jsonrpc_stream_success(cmd); response = jsonrpc_stream_success(cmd);
json_add_bool(response, "enabled", false); json_add_bool(response, "enabled", false);
return command_finished(cmd, response); return command_finished(cmd, response);
} }
tal_free(cleantimer);
cleantimer = plugin_timer(cmd->plugin, time_from_sec(cycle_seconds), cleantimer = plugin_timer(cmd->plugin, time_from_sec(cycle_seconds),
do_clean, cmd->plugin); do_clean, cmd->plugin);

View file

@ -559,7 +559,6 @@ def test_waitanyinvoice_reversed(node_factory, executor):
assert r['label'] == 'inv1' assert r['label'] == 'inv1'
@pytest.mark.xfail(strict=True)
def test_autocleaninvoice(node_factory): def test_autocleaninvoice(node_factory):
l1 = node_factory.get_node() l1 = node_factory.get_node()