Seen with GCC 15.2.1, resulting in the following coreutils failures: $ src/printf '%.0f\n' 0 lib/vasnprintf.c:875:7: runtime error: null pointer passed as argument 2, which is declared to never be null
$ src/seq -0 0 lib/vasnprintf.c:875:7: runtime error: null pointer passed as argument 2, which is declared to never be null lib/vasnprintf.c (divide): Avoid the undefined memcpy (..., NULL, 0). --- ChangeLog | 5 +++++ lib/vasnprintf.c | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index e9eef97cd5..f2600df091 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2025-11-05 Pádraig Brady <[email protected]> + + vasnprintf: avoid -fsanitize=undefined failure + lib/vasnprintf.c (divide): Avoid the undefined memcpy (..., NULL, 0). + 2025-11-04 Collin Funk <[email protected]> nproc: Fix compilation error with Android API ≤ 20. diff --git a/lib/vasnprintf.c b/lib/vasnprintf.c index 5ca73e92a7..4e8fa128fb 100644 --- a/lib/vasnprintf.c +++ b/lib/vasnprintf.c @@ -872,7 +872,8 @@ divide (mpn_t a, mpn_t b, mpn_t *q) /* m<n: trivial case. q=0, r := copy of a. */ r_ptr = roomptr; r_len = a_len; - memcpy (r_ptr, a_ptr, a_len * sizeof (mp_limb_t)); + if (a_len) + memcpy (r_ptr, a_ptr, a_len * sizeof (mp_limb_t)); q_ptr = roomptr + a_len; q_len = 0; } -- 2.51.1
