mirror of
https://git.savannah.gnu.org/git/gnulib.git
synced 2025-08-10 04:43:00 +03:00
* doc/glibc-functions/reallocarray.texi (reallocarray): Mention ptrdiff_t overflow. * lib/reallocarray.c (reallocarray): Reindent as per usual GNU. * lib/stdlib.in.h (reallocarray): Allow reallocarray to be replaced. * m4/reallocarray.m4 (gl_FUNC_REALLOCARRAY): Check for ptrdiff_t overflow. * m4/stdlib_h.m4 (gl_STDLIB_H_DEFAULTS): Set up REPLACE_REALLOCARRAY. * modules/reallocarray (Files): Add malloc.m4. (configure.ac): Also test REPLACE_REALLOCARRAY. * modules/reallocarray-tests (Depends-on): Add stdint. * modules/stdlib (stdlib.h): Substitute REPLACE_REALLOCARRAY. * tests/test-reallocarray.c: Include stdint.h. (main): Check for ptrdiff_t overflow.
40 lines
1.2 KiB
Plaintext
40 lines
1.2 KiB
Plaintext
@node reallocarray
|
|
@subsection @code{reallocarray}
|
|
@findex reallocarray
|
|
|
|
Documentation:
|
|
@itemize
|
|
@item
|
|
@ifinfo
|
|
@ref{Changing Block Size,,Changing the Size of a Block,libc},
|
|
@end ifinfo
|
|
@ifnotinfo
|
|
@url{https://www.gnu.org/software/libc/manual/html_node/Changing-Block-Size.html},
|
|
@end ifnotinfo
|
|
@item
|
|
@uref{https://www.kernel.org/doc/man-pages/online/pages/man3/reallocarray.3.html,,man reallocarray}.
|
|
@end itemize
|
|
|
|
Gnulib module: reallocarray
|
|
|
|
Allocate multiple memory locations of a fixed size with integer overflow
|
|
protection.
|
|
Glibc Manual: @url{https://www.gnu.org/software/libc/manual/html_node/Changing-Block-Size.html#Changing-Block-Size}
|
|
|
|
Portability problems fixed by Gnulib:
|
|
@itemize
|
|
@item
|
|
This function is missing on many platforms:
|
|
glibc 2.25, macOS 11.1, FreeBSD 10, NetBSD 7, OpenBSD 5.5, Minix 3.3.0, AIX 7.2, HP-UX 11, IRIX, Solaris 11.4, Cygwin 1.7.x, mingw, MSVC 14, Android 9.0.
|
|
|
|
@item
|
|
On some platforms, @code{reallocarray (n, s)} can succeed even if
|
|
multiplying @code{n} by @code{s} would exceed @code{PTRDIFF_MAX},
|
|
which can lead to undefined behavior later:
|
|
FreeBSD 13, NetBSD 9, OpenBSD 6, musl 1.2.
|
|
@end itemize
|
|
|
|
Portability problems not fixed by Gnulib:
|
|
@itemize
|
|
@end itemize
|