common: fix ubsan trigger in param test.

```
common/test/run-param.c:381:8: runtime error: applying zero offset to null pointer
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior common/test/run-param.c:381:8
```

Probably because CI now on 24.04, so more recent clang.  But the test really does
want to see what happens when the callback is NULL, so workaround.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2026-01-05 09:32:44 +10:30
parent 2bba6f0d3a
commit 8f09f0c154

View File

@@ -376,9 +376,18 @@ static void bad_programmer(void)
p_req("repeat", param_millionths, &fpval), NULL);
assert(paramcheck_assert_failed);
/* UBSan gets upset with doing arith on NULL pointers, inside
* the p_req macro, so we do it raw here */
#define p_req_raw(name, cbx, arg) \
name"", \
PARAM_REQUIRED, \
NULL, NULL, \
(param_cbx)(cbx), \
(arg)
paramcheck_assert_failed = false;
param(cmd, j->buffer, j->toks,
p_req("u64", (param_cbx) NULL, NULL), NULL);
p_req_raw("u64", NULL, NULL), NULL);
assert(paramcheck_assert_failed);
/* Add required param after optional */