From ad3cbed7c28b2d4e9327885f6c3763f8f4acef41 Mon Sep 17 00:00:00 2001 From: Simon Vrouwe Date: Thu, 14 Jul 2022 12:40:11 +0300 Subject: [PATCH] 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. --- plugins/autoclean.c | 4 +++- tests/test_invoices.py | 1 - 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/plugins/autoclean.c b/plugins/autoclean.c index c4d29fc02..27c91e2e4 100644 --- a/plugins/autoclean.c +++ b/plugins/autoclean.c @@ -48,12 +48,14 @@ static struct command_result *json_autocleaninvoice(struct command *cmd, cycle_seconds = *cycle; expired_by = *exby; + cleantimer = tal_free(cleantimer); + if (cycle_seconds == 0) { response = jsonrpc_stream_success(cmd); json_add_bool(response, "enabled", false); return command_finished(cmd, response); } - tal_free(cleantimer); + cleantimer = plugin_timer(cmd->plugin, time_from_sec(cycle_seconds), do_clean, cmd->plugin); diff --git a/tests/test_invoices.py b/tests/test_invoices.py index b2cb94837..ccce09218 100644 --- a/tests/test_invoices.py +++ b/tests/test_invoices.py @@ -559,7 +559,6 @@ def test_waitanyinvoice_reversed(node_factory, executor): assert r['label'] == 'inv1' -@pytest.mark.xfail(strict=True) def test_autocleaninvoice(node_factory): l1 = node_factory.get_node()