* lib/malloc.c: Include stdckdint.h, xalloc-oversized.h.
(rpl_malloc): Use ckd_mul instead of xalloc_oversized.
* modules/malloc-gnu, modules/malloc-posix:
(Depends-on): Depend on stdckdint, not xalloc-oversized.
---
 ChangeLog            | 6 ++++++
 lib/malloc.c         | 6 +++---
 modules/malloc-gnu   | 2 +-
 modules/malloc-posix | 2 +-
 4 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index af6fce7f00..d9c9cad52c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
 2024-11-04  Paul Eggert  <egg...@cs.ucla.edu>
 
+       malloc-gnu: depend on stdckdint not xalloc-oversized
+       * lib/malloc.c: Include stdckdint.h, xalloc-oversized.h.
+       (rpl_malloc): Use ckd_mul instead of xalloc_oversized.
+       * modules/malloc-gnu, modules/malloc-posix:
+       (Depends-on): Depend on stdckdint, not xalloc-oversized.
+
        calloc: depend on stdckdint not xalloc-oversized
        * lib/calloc.c: Include stdckdint.h, xalloc-oversized.h.
        (rpl_calloc): Use ckd_mul instead of xalloc_oversized.
diff --git a/lib/malloc.c b/lib/malloc.c
index 2a7867a1d1..90018863ea 100644
--- a/lib/malloc.c
+++ b/lib/malloc.c
@@ -23,8 +23,7 @@
 #include <stdlib.h>
 
 #include <errno.h>
-
-#include "xalloc-oversized.h"
+#include <stdckdint.h>
 
 /* Allocate an N-byte block of memory from the heap, even if N is 0.  */
 
@@ -34,7 +33,8 @@ rpl_malloc (size_t n)
   if (n == 0)
     n = 1;
 
-  if (xalloc_oversized (n, 1))
+  ptrdiff_t signed_n;
+  if (ckd_add (&signed_n, n, 0))
     {
       errno = ENOMEM;
       return NULL;
diff --git a/modules/malloc-gnu b/modules/malloc-gnu
index 95227241d0..13b26693b7 100644
--- a/modules/malloc-gnu
+++ b/modules/malloc-gnu
@@ -7,7 +7,7 @@ lib/malloc.c
 Depends-on:
 malloc-posix
 extensions-aix
-xalloc-oversized     [test $REPLACE_MALLOC_FOR_MALLOC_GNU = 1]
+stdckdint            [test $REPLACE_CALLOC_FOR_MALLOC_GNU = 1]
 
 configure.ac:
 gl_FUNC_MALLOC_GNU
diff --git a/modules/malloc-posix b/modules/malloc-posix
index 86687aa8aa..a3efe4ca7b 100644
--- a/modules/malloc-posix
+++ b/modules/malloc-posix
@@ -6,8 +6,8 @@ lib/malloc.c
 m4/malloc.m4
 
 Depends-on:
+stdckdint            [test $REPLACE_CALLOC_FOR_MALLOC_POSIX = 1]
 stdlib
-xalloc-oversized     [test $REPLACE_MALLOC_FOR_MALLOC_POSIX = 1]
 
 configure.ac:
 AC_REQUIRE([gl_FUNC_MALLOC_POSIX])
-- 
2.43.0


Reply via email to