# HG changeset patch # User Paul Eggert # Date 1481824613 28800 # Node ID ab7a57bd5e3bfffddd5ea4dfe45b6371e71a3f74 # Parent 909a440ad7115f73873eb1e1388a3f91422a1c5b 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. diff -r 909a440ad711 -r ab7a57bd5e3b ChangeLog --- a/ChangeLog Thu Dec 15 09:53:45 2016 -0800 +++ b/ChangeLog Thu Dec 15 09:56:53 2016 -0800 @@ -1,5 +1,12 @@ 2016-12-15 Paul Eggert + 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. diff -r 909a440ad711 -r ab7a57bd5e3b lib/malloca.h --- a/lib/malloca.h Thu Dec 15 09:53:45 2016 -0800 +++ b/lib/malloca.h Thu Dec 15 09:56:53 2016 -0800 @@ -21,6 +21,9 @@ #include #include #include +#include + +#include "xalloc-oversized.h" #ifdef __cplusplus @@ -73,15 +76,7 @@ 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 diff -r 909a440ad711 -r ab7a57bd5e3b modules/malloca --- a/modules/malloca Thu Dec 15 09:53:45 2016 -0800 +++ b/modules/malloca Thu Dec 15 09:56:53 2016 -0800 @@ -12,6 +12,7 @@ Depends-on: alloca-opt stdint +xalloc-oversized verify configure.ac: diff -r 909a440ad711 -r ab7a57bd5e3b modules/relocatable-prog-wrapper --- a/modules/relocatable-prog-wrapper Thu Dec 15 09:53:45 2016 -0800 +++ b/modules/relocatable-prog-wrapper Thu Dec 15 09:56:53 2016 -0800 @@ -47,6 +47,7 @@ environ string verify +xalloc-oversized configure.ac: gl_FUNC_READLINK_SEPARATE