Paul Eggert wrote: > @@ -63,9 +67,15 @@ xcharalloc (size_t n) > void * > xrealloc (void *p, size_t s) > { > - void *r = realloc (p, s); > - if (!r && (!p || s)) > + /* Work around realloc glitch by treating a 0 size as if it were 1, > + to avoid undefined behavior in strict C23 platforms, > + so that returning NULL is equivalent to failing. */ > + void *r = realloc (p, s ? s : 1); > + if (!r) > xalloc_die ();
After this change, 'xalloc' does not need the 'realloc-gnu' module any more. 2024-10-25 Bruno Haible <br...@clisp.org> xalloc: Adjust dependencies after last change. * modules/xalloc (Depends-on): Remove realloc-gnu. Add realloc-posix. diff --git a/modules/xalloc b/modules/xalloc index 15059bf47f..3ff92ae57f 100644 --- a/modules/xalloc +++ b/modules/xalloc @@ -14,7 +14,7 @@ ialloc idx malloc-gnu minmax -realloc-gnu +realloc-posix reallocarray stdckdint stdint