From bbdcf5a704517d35a76ba8b666075da9ffe39ac4 Mon Sep 17 00:00:00 2001 From: RincewindsHat <12514511+RincewindsHat@users.noreply.github.com> Date: Tue, 23 Aug 2022 17:13:04 +0200 Subject: Sync with the latest Gnulib code (fa1ac7ec) --- gl/malloca.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'gl/malloca.c') diff --git a/gl/malloca.c b/gl/malloca.c index b4884234..183783a7 100644 --- a/gl/malloca.c +++ b/gl/malloca.c @@ -1,5 +1,5 @@ /* Safe automatic memory allocation. - Copyright (C) 2003, 2006-2007, 2009-2021 Free Software Foundation, Inc. + Copyright (C) 2003, 2006-2007, 2009-2022 Free Software Foundation, Inc. Written by Bruno Haible , 2003, 2018. This file is free software: you can redistribute it and/or modify @@ -21,8 +21,9 @@ /* Specification. */ #include "malloca.h" +#include + #include "idx.h" -#include "intprops.h" #include "verify.h" /* The speed critical point in this file is freea() applied to an alloca() @@ -50,17 +51,16 @@ mmalloca (size_t n) uintptr_t alignment2_mask = 2 * sa_alignment_max - 1; int plus = sizeof (small_t) + alignment2_mask; idx_t nplus; - if (!INT_ADD_WRAPV (n, plus, &nplus) && !xalloc_oversized (nplus, 1)) + if (!ckd_add (&nplus, n, plus) && !xalloc_oversized (nplus, 1)) { char *mem = (char *) malloc (nplus); if (mem != NULL) { uintptr_t umem = (uintptr_t)mem, umemplus; - /* The INT_ADD_WRAPV avoids signed integer overflow on + /* The ckd_add avoids signed integer overflow on theoretical platforms where UINTPTR_MAX <= INT_MAX. */ - INT_ADD_WRAPV (umem, sizeof (small_t) + sa_alignment_max - 1, - &umemplus); + ckd_add (&umemplus, umem, sizeof (small_t) + sa_alignment_max - 1); idx_t offset = ((umemplus & ~alignment2_mask) + sa_alignment_max - umem); void *vp = mem + offset; -- cgit v1.2.3-74-g34f1