mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-02-22 14:42:40 +01:00
channeld: fix memleak when inflights is NULL.
In this case, we were allocating off NULL, which meant a leak: ``` MEMLEAK: 0x565086722e98 label=channeld/channeld.c:3433:struct inflight backtrace: ccan/ccan/tal/tal.c:477 (tal_alloc_) channeld/channeld.c:3433 (inflights_new) channeld/channeld.c:3573 (splice_accepter) channeld/channeld.c:4145 (peer_in) channeld/channeld.c:6051 (main) parents: ``` Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
181d6cc908
commit
e21bcbfbb9
1 changed files with 5 additions and 8 deletions
|
@ -3430,17 +3430,14 @@ static void resume_splice_negotiation(struct peer *peer,
|
|||
|
||||
static struct inflight *inflights_new(struct peer *peer)
|
||||
{
|
||||
struct inflight *inf = tal(peer->splice_state->inflights,
|
||||
struct inflight);
|
||||
int i = tal_count(peer->splice_state->inflights);
|
||||
struct inflight *inf;
|
||||
|
||||
if (i)
|
||||
tal_resize(&peer->splice_state->inflights, i + 1);
|
||||
else
|
||||
if (!peer->splice_state->inflights)
|
||||
peer->splice_state->inflights = tal_arr(peer->splice_state,
|
||||
struct inflight *, 1);
|
||||
struct inflight *, 0);
|
||||
|
||||
peer->splice_state->inflights[i] = inf;
|
||||
inf = tal(peer->splice_state->inflights, struct inflight);
|
||||
tal_arr_expand(&peer->splice_state->inflights, inf);
|
||||
return inf;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue