AtlatestRepositorycore-channel

core-channel / tree / src / patchessamurai-realloc-zero-length.patch

1--- a/util.c 2026-08-24 12:58:01.409014074 +0300
2+++ b/util.c 2026-08-24 12:58:01.414746803 +0300
3@@ -64,7 +64,14 @@
4 errno = ENOMEM;
5 return NULL;
6 }
7- return realloc(p, n * m);
8+ /* realloc(p, 0) is NOT required to return a non-null pointer, and
9+ xreallocarray() below treats null as failure. This toolchain's
10+ libc returns null for realloc(NULL, 0) while malloc(0) returns
11+ non-null, so deps.c's zero-length save on a fresh build
12+ directory aborts with a bogus "reallocarray" error. Ask for one
13+ byte instead; every caller of a zero-length result copies zero
14+ bytes into it. */
15+ return realloc(p, n * m ? n * m : 1);
16 }
18 void *