mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-02-22 14:42:40 +01:00
pay: Use safe list traversal when completing suspended payments
When traversing the list we call `command_finished` which modifies the list we are traversing. This ensures we don't end up advancing in the list iteration. Reported-by: Rusty Russell <@rustyrussell>
This commit is contained in:
parent
65a449e2c3
commit
da0b651803
1 changed files with 4 additions and 4 deletions
|
@ -574,7 +574,7 @@ static const char *init(struct plugin *p,
|
|||
|
||||
static void on_payment_success(struct payment *payment)
|
||||
{
|
||||
struct payment *p;
|
||||
struct payment *p, *nxt;
|
||||
struct payment_tree_result result = payment_collect_result(payment);
|
||||
struct json_stream *ret;
|
||||
struct command *cmd;
|
||||
|
@ -585,7 +585,7 @@ static void on_payment_success(struct payment *payment)
|
|||
/* Iterate through any pending payments we suspended and
|
||||
* terminate them. */
|
||||
|
||||
list_for_each(&payments, p, list) {
|
||||
list_for_each_safe(&payments, p, nxt, list) {
|
||||
/* The result for the active payment is returned in
|
||||
* `payment_finished`. */
|
||||
if (payment == p)
|
||||
|
@ -672,9 +672,9 @@ static void payment_json_add_attempts(struct json_stream *s,
|
|||
|
||||
static void on_payment_failure(struct payment *payment)
|
||||
{
|
||||
struct payment *p;
|
||||
struct payment *p, *nxt;
|
||||
struct payment_tree_result result = payment_collect_result(payment);
|
||||
list_for_each(&payments, p, list)
|
||||
list_for_each_safe(&payments, p, nxt, list)
|
||||
{
|
||||
struct json_stream *ret;
|
||||
struct command *cmd;
|
||||
|
|
Loading…
Add table
Reference in a new issue