1
0
mirror of https://https.git.savannah.gnu.org/git/gnulib.git synced 2026-05-13 07:03:33 +00:00
Files
gnulib/modules/xmalloca
Paul Eggert cc98a5e2fd xmalloca, etc.: fix some xalloc-oversized issues
* lib/malloca.h (nmalloca):
* lib/xmalloca.h (xnmalloca): Convert S to ptrdiff_t to avoid
arithmetic overflow if N and S are both narrower than ptrdiff_t.
* lib/xalloc-oversized.h (xalloc_oversized):
Don’t say that args must be ptrdiff_t or size_t or wider.
The macro returns the correct answer even when that is not
the case, and it’s the caller’s responsibility to avoid
howlers like (xalloc_oversized (n, s) ? NULL : malloc (n * s))
when N and S are both narrower than ptrdiff_t and size_t.
Add a comment to that effect.
* lib/xmalloca.h: Include xalloc-oversized.h, since this file uses
xalloc_oversized.  Add comments about side effects and avoid
unnecessary parens.
* modules/xmalloca (Depends-on): Add xalloc-oversized.
2021-04-24 18:00:47 -07:00

26 lines
267 B
Plaintext

Description:
Safe automatic memory allocation with out of memory checking.
Files:
lib/xmalloca.h
lib/xmalloca.c
Depends-on:
malloca
xalloc
xalloc-oversized
configure.ac:
Makefile.am:
lib_SOURCES += xmalloca.c
Include:
"xmalloca.h"
License:
GPL
Maintainer:
all