Skip to content

Commit 090f4b0

Browse files
Storm Knightdaywalker90
authored andcommitted
lightningd/peer_control: initialize error pointer in handle_peer_spoke
The local variable `error` in handle_peer_spoke() is declared as a pointer type with no initialization. Several error paths jump to the `send_error` label where `error` is dereferenced (passed to tal_hex() and towire_connectd_peer_send_msg()). While sockpair() currently sets the `error` pointer via the output parameter on failure, the declaration should be initialized to NULL as a defensive measure and to avoid undefined behavior if code paths change. Fixes #8849 Changelog-Fixed: peer_control: initialize error pointer in handle_peer_spoke to NULL to prevent undefined behavior on error paths.
1 parent c4fe4cb commit 090f4b0

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

‎lightningd/peer_control.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2017,7 +2017,7 @@ void handle_peer_spoke(struct lightningd *ld, const u8 *msg)
20172017
struct channel_id channel_id;
20182018
struct peer *peer;
20192019
bool dual_fund;
2020-
const u8 *error;
2020+
const u8 *error = NULL;
20212021
int other_fd;
20222022
struct peer_fd *pfd;
20232023
char *errmsg;

0 commit comments

Comments
 (0)