Skip to content

Commit 946f4de

Browse files
committed
descriptor: require an extra byte to generate raw expressions
raw() with no arguments generates a zero length script. Ensure we tell the caller they need at least one byte of generation space for this case, otherwise they would be passing an invalid (empty) output buffer.
1 parent bdde10c commit 946f4de

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/descriptor.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2546,8 +2546,12 @@ static int node_generation_size(const ms_node *node, size_t *total)
25462546
/* max of p2pk, p2pkh, p2wpkh, or p2sh-p2wpkh */
25472547
*total += WALLY_SCRIPTPUBKEY_P2PKH_LEN;
25482548
break;
2549-
case KIND_DESCRIPTOR_ADDR:
25502549
case KIND_DESCRIPTOR_RAW:
2550+
/* Add an extra byte to handle 'raw()' which results in nothing,
2551+
* as empty output buffers cannot be passed to descriptor calls.
2552+
*/
2553+
*total += 1;
2554+
case KIND_DESCRIPTOR_ADDR:
25512555
/* No-op */
25522556
break;
25532557
case KIND_DESCRIPTOR_RAW_TR:

0 commit comments

Comments
 (0)