Skip to content

Commit c05d7e4

Browse files
morehousecdecker
authored andcommitted
bitcoin: avoid adding to NULL
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
1 parent 73b7348 commit c05d7e4

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

common/utils.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,10 +123,10 @@ void tal_wally_end(const tal_t *parent);
123123
/* ... or this if you want to reparent onto something which is
124124
* allocated by libwally here. Fixes up this from_wally obj to have a
125125
* proper tal_name, too! */
126-
#define tal_wally_end_onto(parent, from_wally, type) \
127-
tal_wally_end_onto_((parent), \
128-
(from_wally) + 0*sizeof((from_wally) == (type *)0), \
129-
stringify(type))
126+
#define tal_wally_end_onto(parent, from_wally, type) \
127+
tal_wally_end_onto_( \
128+
(parent), (from_wally), \
129+
&stringify(type)[0 * sizeof((from_wally) == (type *)0)])
130130
void tal_wally_end_onto_(const tal_t *parent,
131131
tal_t *from_wally,
132132
const char *from_wally_name);

0 commit comments

Comments
 (0)