Date: Mon, 15 Dec 2025 02:04:44 +0000 From: bugzilla-noreply@freebsd.org To: bugs@FreeBSD.org Subject: [Bug 291677] FreeBSD 15.0 realloc does not set errno for large size values Message-ID: <bug-291677-227@https.bugs.freebsd.org/bugzilla/>
index | next in thread | raw e-mail
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=291677 Bug ID: 291677 Summary: FreeBSD 15.0 realloc does not set errno for large size values Product: Base System Version: 15.0-CURRENT Hardware: Any OS: Any Status: New Severity: Affects Some People Priority: --- Component: bin Assignee: bugs@FreeBSD.org Reporter: collin.funk1@gmail.com Using the following test program: ``` $ cat main.c #include <errno.h> #include <inttypes.h> #include <stdio.h> #include <stdlib.h> int main (int argc, char *argv[]) { errno = 1729; void *p = malloc (1); printf ("p = 0x%jx, errno = %d\n", (uintmax_t) p, errno); p = realloc (p, PTRDIFF_MAX); printf ("p = 0x%jx, errno = %d\n", (uintmax_t) p, errno); } ``` Here is the output on FreeBSD 14.3: ``` $ uname -r && cc main.c && ./a.out 14.3-RELEASE-p5 p = 0x2bf54fe08008, errno = 1729 p = 0x0, errno = 12 ``` Here is the output on FreeBSD 15.0: ``` $ uname -r && cc main.c && ./a.out 15.0-RELEASE p = 0x1b6e8dc08000, errno = 1729 p = 0x0, errno = 1729 ``` So for large size values on FreeBSD 15.0 `realloc` fails but does not set `errno` to `ENOMEM` like FreeBSD 14.3. This was found in the Gnulib test suite by Bruno Haible [1]. He wrote: > The reason is that realloc (p, size) sets errno when failing only when > size <= 0x700000000000000; it leaves errno untouched if > size > 0x700000000000000. [1] https://lists.gnu.org/archive/html/bug-gnulib/2025-12/msg00021.html -- You are receiving this mail because: You are the assignee for the bug.help
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-291677-227>
