From d6a3b8f0874f548838f28a1303b2c8a0ae3ac7df Mon Sep 17 00:00:00 2001 From: Paul Eggert <eggert@cs.ucla.edu> Date: Sat, 3 Feb 2018 00:47:15 +0100 Subject: [PATCH] malloca: Add a compile-time verification. * lib/malloca.c (small_t): Verify that it is wide enough. * modules/malloca (Depends-on): Add verify. --- ChangeLog | 6 ++++++ lib/malloca.c | 4 ++++ modules/malloca | 1 + 3 files changed, 11 insertions(+) diff --git a/ChangeLog b/ChangeLog index 85c13f8714..43731aee28 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2018-02-02 Paul Eggert <eggert@cs.ucla.edu> + + malloca: Add a compile-time verification. + * lib/malloca.c (small_t): Verify that it is wide enough. + * modules/malloca (Depends-on): Add verify. + 2018-02-02 Bruno Haible <bruno@clisp.org> malloca: Add an argument check. diff --git a/lib/malloca.c b/lib/malloca.c index c5321d17e9..c66e0c88e6 100644 --- a/lib/malloca.c +++ b/lib/malloca.c @@ -21,6 +21,8 @@ /* Specification. */ #include "malloca.h" +#include "verify.h" + /* The speed critical point in this file is freea() applied to an alloca() result: it must be fast, to match the speed of alloca(). The speed of mmalloca() and freea() in the other case are not critical, because they @@ -34,6 +36,8 @@ /* Type for holding very small pointer differences. */ typedef unsigned char small_t; +/* Verify that it is wide enough. */ +verify (2 * sa_alignment_max - 1 <= (small_t) -1); void * mmalloca (size_t n) diff --git a/modules/malloca b/modules/malloca index 8f5ab644a7..0ae3fe08dc 100644 --- a/modules/malloca +++ b/modules/malloca @@ -11,6 +11,7 @@ m4/longlong.m4 Depends-on: alloca-opt stdint +verify xalloc-oversized configure.ac: -- 2.39.5