1
0
mirror of https://git.savannah.gnu.org/git/gnulib.git synced 2025-08-10 04:43:00 +03:00

malloca: do not exceed PTRDIFF_MAX

* lib/malloca.h: Include xalloc-oversized.
(nmalloca): Use xalloc_oversized instead of rolling our own.
* modules/malloca (Depends-on):
* modules/relocatable-prog-wrapper (Depends-on):
Add xalloc-oversized.
This commit is contained in:
Paul Eggert
2016-12-15 09:56:53 -08:00
parent cb4e027f61
commit ca495b0f87
4 changed files with 13 additions and 9 deletions

View File

@@ -1,5 +1,12 @@
2016-12-15 Paul Eggert <eggert@cs.ucla.edu>
malloca: do not exceed PTRDIFF_MAX
* lib/malloca.h: Include xalloc-oversized.
(nmalloca): Use xalloc_oversized instead of rolling our own.
* modules/malloca (Depends-on):
* modules/relocatable-prog-wrapper (Depends-on):
Add xalloc-oversized.
quotearg: pacify GCC better
* modules/quotearg (Depends-on): Add minmax, stdint.
* lib/quotearg.c: Include minmax.h, stdint.h.

View File

@@ -21,6 +21,9 @@
#include <alloca.h>
#include <stddef.h>
#include <stdlib.h>
#include <stdint.h>
#include "xalloc-oversized.h"
#ifdef __cplusplus
@@ -73,15 +76,7 @@ extern void freea (void *p);
It allocates an array of N objects, each with S bytes of memory,
on the stack. S must be positive and N must be nonnegative.
The array must be freed using freea() before the function returns. */
#if 1
/* Cf. the definition of xalloc_oversized. */
# define nmalloca(n, s) \
((n) > (size_t) (sizeof (ptrdiff_t) <= sizeof (size_t) ? -1 : -2) / (s) \
? NULL \
: malloca ((n) * (s)))
#else
extern void * nmalloca (size_t n, size_t s);
#endif
#define nmalloca(n, s) (xalloc_oversized (n, s) ? NULL : malloca ((n) * (s)))
#ifdef __cplusplus

View File

@@ -12,6 +12,7 @@ m4/longlong.m4
Depends-on:
alloca-opt
stdint
xalloc-oversized
verify
configure.ac:

View File

@@ -47,6 +47,7 @@ unistd
environ
string
verify
xalloc-oversized
configure.ac:
gl_FUNC_READLINK_SEPARATE