summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2021-04-24 17:59:53 -0700
committerPaul Eggert <eggert@cs.ucla.edu>2021-04-24 18:00:47 -0700
commitcc98a5e2fd16ae8589deea9dbd71be59b6f77305 (patch)
tree5cfda2d9701be2b35c5c8447f319402655188581 /modules
parenta7477abe2943c73bf23f39da2b706ea338d1c9b3 (diff)
downloadgnulib-cc98a5e2fd16ae8589deea9dbd71be59b6f77305.tar.gz
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.
Diffstat (limited to 'modules')
-rw-r--r--modules/xmalloca1
1 files changed, 1 insertions, 0 deletions
diff --git a/modules/xmalloca b/modules/xmalloca
index dac01f2d22..92b965b82a 100644
--- a/modules/xmalloca
+++ b/modules/xmalloca
@@ -8,6 +8,7 @@ lib/xmalloca.c
Depends-on:
malloca
xalloc
+xalloc-oversized
configure.ac: