mirror of
https://github.com/aljazceru/lightning.git
synced 2026-01-06 07:34:21 +01:00
memleak: handle libwally allocations better.
Things allocated by libwally all get the tal_name "wally_tal", which cost me a few hours trying to find a leak. In the case where we're making one of the allocations the parent of the others (e.g. a wally_psbt), we can do better: supply a name for the tal_wally_end(). So I add a new tal_wally_end_onto() which does the standard tal_steal() trick, and also changes the (typechecked!) name. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
@@ -179,7 +179,7 @@ mfc_cleanup_psbt(struct command *cmd,
|
||||
tal_wally_start();
|
||||
if (wally_psbt_clone_alloc(psbt, 0, &pruned_psbt) != WALLY_OK)
|
||||
abort();
|
||||
tal_wally_end(tal_steal(NULL, pruned_psbt));
|
||||
tal_wally_end_onto(NULL, pruned_psbt, struct wally_psbt);
|
||||
|
||||
for (size_t i = pruned_psbt->num_inputs - 1;
|
||||
i < pruned_psbt->num_inputs;
|
||||
|
||||
@@ -76,7 +76,7 @@ static bool update_parent_psbt(const tal_t *ctx,
|
||||
tal_wally_start();
|
||||
if (wally_psbt_clone_alloc(*parent_psbt, 0, &clone) != WALLY_OK)
|
||||
abort();
|
||||
tal_wally_end(tal_steal(ctx, clone));
|
||||
tal_wally_end_onto(ctx, clone, struct wally_psbt);
|
||||
|
||||
/* This makes it such that we can reparent/steal added
|
||||
* inputs/outputs without impacting the 'original'. We
|
||||
@@ -261,7 +261,7 @@ static bool update_node_psbt(const tal_t *ctx,
|
||||
/* Only failure is alloc */
|
||||
if (wally_psbt_clone_alloc(parent_psbt, 0, &clone) != WALLY_OK)
|
||||
abort();
|
||||
tal_wally_end(tal_steal(ctx, clone));
|
||||
tal_wally_end_onto(ctx, clone, struct wally_psbt);
|
||||
|
||||
/* For every peer's input/output, flip the serial id
|
||||
* on the clone. They should all be present. */
|
||||
@@ -958,7 +958,7 @@ openchannel_init_ok(struct command *cmd,
|
||||
* logic in `perform_openchannel_update` the same. */
|
||||
tal_wally_start();
|
||||
wally_psbt_clone_alloc(dest->updated_psbt, 0, &dest->psbt);
|
||||
tal_wally_end(tal_steal(mfc, dest->updated_psbt));
|
||||
tal_wally_end_onto(mfc, dest->updated_psbt, struct wally_psbt);
|
||||
return openchannel_init_done(dest);
|
||||
}
|
||||
|
||||
@@ -998,7 +998,7 @@ openchannel_init_dest(struct multifundchannel_destination *dest)
|
||||
/* Copy the original parent down */
|
||||
tal_wally_start();
|
||||
wally_psbt_clone_alloc(mfc->psbt, 0, &dest->psbt);
|
||||
tal_wally_end(tal_steal(mfc, dest->psbt));
|
||||
tal_wally_end_onto(mfc, dest->psbt, struct wally_psbt);
|
||||
|
||||
json_add_psbt(req->js, "initialpsbt", dest->psbt);
|
||||
if (mfc->cmtmt_feerate_str)
|
||||
|
||||
Reference in New Issue
Block a user