Hash :
cc98a5e2
Author :
Date :
2021-04-24T17:59:53
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.
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