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
This commit is contained in:
Matt Morehouse 2023-04-07 12:57:10 -05:00 committed by Christian Decker
parent 73b73483bf
commit c05d7e4f78
1 changed files with 4 additions and 4 deletions

View File

@ -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);