AtlatestRepositorycore-channel
core-channel / tree / src / patchessamurai-realloc-zero-length.patch
1
--- a/util.c 2026-08-24 12:58:01.409014074 +03002
+++ b/util.c 2026-08-24 12:58:01.414746803 +03003
@@ -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, and9
+ xreallocarray() below treats null as failure. This toolchain's10
+ libc returns null for realloc(NULL, 0) while malloc(0) returns11
+ non-null, so deps.c's zero-length save on a fresh build12
+ directory aborts with a bogus "reallocarray" error. Ask for one13
+ byte instead; every caller of a zero-length result copies zero14
+ bytes into it. */15
+ return realloc(p, n * m ? n * m : 1);16
}18
void *