Skip to content

Commit 2eeec53

Browse files
author
Storm Knight
committed
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
1 parent c4c4d81 commit 2eeec53

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lightningd/peer_control.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1993,7 +1993,7 @@ void handle_peer_spoke(struct lightningd *ld, const u8 *msg)
19931993
struct channel_id channel_id;
19941994
struct peer *peer;
19951995
bool dual_fund;
1996-
const u8 *error;
1996+
const u8 *error = NULL;
19971997
int other_fd;
19981998
struct peer_fd *pfd;
19991999
char *errmsg;

0 commit comments

Comments
 (0)