diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2021-04-24 18:13:40 -0700 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2021-04-24 18:14:06 -0700 |
commit | 724f02cffadca0f63828537d018247f48ee115c0 (patch) | |
tree | 9b99b281db18c575d5294bf8eb1cc32887ee2023 /lib/xmalloca.h | |
parent | cc98a5e2fd16ae8589deea9dbd71be59b6f77305 (diff) | |
download | gnulib-724f02cffadca0f63828537d018247f48ee115c0.tar.gz |
xmalloca, etc.: avoid unlikely trap
* lib/xmalloca.h (xnmalloca):
Use size_t, not ptrdiff_t, to avoid implementation-defined
behavior (which could include a trap) if N is 0 and S exceeds
PTRDIFF_MAX.
* lib/xalloc-oversized.h: Adjust comment to match.
Diffstat (limited to 'lib/xmalloca.h')
-rw-r--r-- | lib/xmalloca.h | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/xmalloca.h b/lib/xmalloca.h index c7815f6171..dbc648697e 100644 --- a/lib/xmalloca.h +++ b/lib/xmalloca.h @@ -54,7 +54,7 @@ extern void * xmmalloca (size_t n); #if HAVE_ALLOCA /* Rely on xmalloca (SIZE_MAX) calling xalloc_die (). */ # define xnmalloca(n, s) \ - xmalloca (xalloc_oversized (n, s) ? (size_t) (-1) : (n) * (ptrdiff_t) (s)) + xmalloca (xalloc_oversized (n, s) ? (size_t) (-1) : (n) * (size_t) (s)) #else # define xnmalloca(n, s) \ xnmalloc (n, s) |