mirror of
https://github.com/ElementsProject/lightning.git
synced 2026-08-16 13:00:32 +02:00
xpay: fix taken leak if we fail xpay_core early.
This was uncovered by a test in the next commit. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
1f55feec4a
commit
ae956f2a7b
1 changed files with 6 additions and 2 deletions
|
|
@ -2530,6 +2530,10 @@ static struct command_result *xpay_core(struct command *cmd,
|
|||
struct out_req *req;
|
||||
const char *err;
|
||||
|
||||
/* Make our own copy here, in case we exit early. */
|
||||
if (!taken(invstring))
|
||||
invstring = tal_strdup(tmpctx, invstring);
|
||||
|
||||
if (bolt12_has_prefix(invstring)) {
|
||||
struct tlv_invoice *b12inv
|
||||
= invoice_decode(tmpctx, invstring,
|
||||
|
|
@ -2555,7 +2559,7 @@ static struct command_result *xpay_core(struct command *cmd,
|
|||
retryfor,
|
||||
maxdelay,
|
||||
layers,
|
||||
invstring,
|
||||
take(invstring),
|
||||
b12inv->invoice_node_id,
|
||||
b12inv->invoice_payment_hash,
|
||||
amount_msat(*b12inv->invoice_amount),
|
||||
|
|
@ -2651,7 +2655,7 @@ static struct command_result *xpay_core(struct command *cmd,
|
|||
retryfor,
|
||||
maxdelay,
|
||||
layers,
|
||||
invstring,
|
||||
take(invstring),
|
||||
&dst,
|
||||
&b11->payment_hash,
|
||||
*msat,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue