Skip to content
This repository has been archived by the owner on Jun 26, 2024. It is now read-only.

Commit

Permalink
bitcoin: avoid adding to NULL
Browse files Browse the repository at this point in the history
Detected by UBSan:

$ UBSAN_OPTIONS=print_stacktrace=1 ./wallet/test/run-psbt_fixup

bitcoin/psbt.c:733:2: runtime error: applying zero offset to null pointer
    #0 0x53c829 in psbt_from_bytes lightning/bitcoin/psbt.c:733:2
    #1 0x5adcb0 in main lightning/wallet/test/run-psbt_fixup.c:174:10

SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior bitcoin/psbt.c:733:2
  • Loading branch information
morehouse authored and cdecker committed Jun 5, 2023
1 parent 73b7348 commit c05d7e4
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions common/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,10 @@ void tal_wally_end(const tal_t *parent);
/* ... or this if you want to reparent onto something which is
* allocated by libwally here. Fixes up this from_wally obj to have a
* proper tal_name, too! */
#define tal_wally_end_onto(parent, from_wally, type) \
tal_wally_end_onto_((parent), \
(from_wally) + 0*sizeof((from_wally) == (type *)0), \
stringify(type))
#define tal_wally_end_onto(parent, from_wally, type) \
tal_wally_end_onto_( \
(parent), (from_wally), \
&stringify(type)[0 * sizeof((from_wally) == (type *)0)])
void tal_wally_end_onto_(const tal_t *parent,
tal_t *from_wally,
const char *from_wally_name);
Expand Down

0 comments on commit c05d7e4

Please sign in to comment.