Skip to content

Commit

Permalink
lightningd: fix leak report when close called multiple times.
Browse files Browse the repository at this point in the history
```
Global errors:
 - Node /tmp/ltests-odpd7qtt/test_close_twice_1/lightning-1/ has memory leaks: [
    {
        "backtrace": [
            "ccan/ccan/tal/tal.c:442 (tal_alloc_)",
            "ccan/ccan/tal/tal.c:471 (tal_alloc_arr_)",
            "lightningd/peer_control.c:1673 (param_feerate_range)",
            "common/param.c:43 (make_callback)",
            "common/param.c:140 (parse_by_name)",
            "common/param.c:259 (param_arr)",
            "common/param.c:344 (param)",
            "lightningd/peer_control.c:1706 (json_close)",
            "lightningd/jsonrpc.c:643 (command_exec)",
            "lightningd/jsonrpc.c:778 (rpc_command_hook_final)",
            "lightningd/plugin_hook.c:280 (plugin_hook_call_)",
            "lightningd/jsonrpc.c:866 (plugin_hook_call_rpc_command)",
            "lightningd/jsonrpc.c:965 (parse_request)",
            "lightningd/jsonrpc.c:1056 (read_json)",
            "ccan/ccan/io/io.c:59 (next_plan)",
            "ccan/ccan/io/io.c:407 (do_plan)",
            "ccan/ccan/io/io.c:417 (io_ready)",
            "ccan/ccan/io/poll.c:445 (io_loop)",
            "lightningd/io_loop_with_timers.c:24 (io_loop_with_timers)",
            "lightningd/lightningd.c:1123 (main)"
        ],
        "label": "lightningd/peer_control.c:1673:u32[]",
        "parents": [
            "lightningd/channel.c:372:struct channel"
        ],
        "value": "0x56428b886208"
    }
]
```

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
  • Loading branch information
rustyrussell authored and pull[bot] committed Dec 18, 2024
1 parent 1924c98 commit 2076997
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lightningd/peer_control.c
Original file line number Diff line number Diff line change
Expand Up @@ -1871,6 +1871,9 @@ static struct command_result *json_close(struct command *cmd,
wrong_funding_changed = false;
}

/* May already be set by previous close cmd. */
tal_free(channel->closing_feerate_range);

/* Works fine if feerate_range is NULL */
channel->closing_feerate_range = tal_steal(channel, feerate_range);

Expand Down

0 comments on commit 2076997

Please sign in to comment.