Skip to content

Commit 486d321

Browse files
practicalswiftcdecker
authored andcommitted
Avoid NULL pointer dereference in channelseq(...)
1 parent 4452e3f commit 486d321

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

wallet/wallet_tests.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,9 @@ static bool channelseq(struct wallet_channel *c1, struct wallet_channel *c2)
196196
CHECK(p1->their_shachain.id == p2->their_shachain.id);
197197
CHECK_MSG(pubkey_eq(&p1->id, &p2->id), "NodeIDs do not match");
198198
CHECK((p1->scid == NULL && p2->scid == NULL) || short_channel_id_eq(p1->scid, p2->scid));
199-
CHECK((p1->our_msatoshi == NULL && p2->our_msatoshi == NULL) || *p1->our_msatoshi == *p2->our_msatoshi);
199+
CHECK((p1->our_msatoshi == NULL) == (p2->our_msatoshi == NULL));
200+
if (p1->our_msatoshi)
201+
CHECK(*p1->our_msatoshi == *p2->our_msatoshi);
200202
CHECK((p1->remote_shutdown_scriptpubkey == NULL && p2->remote_shutdown_scriptpubkey == NULL) || memeq(
201203
p1->remote_shutdown_scriptpubkey,
202204
tal_len(p1->remote_shutdown_scriptpubkey),

0 commit comments

Comments
 (0)