summaryrefslogtreecommitdiffstats
path: root/gl/malloc.c
diff options
context:
space:
mode:
authorLorenz Kästle <12514511+RincewindsHat@users.noreply.github.com>2025-12-28 12:50:39 +0100
committerGitHub <noreply@github.com>2025-12-28 12:50:39 +0100
commite7dd07c8025b169b7b43b955066a7200d9cdf244 (patch)
tree6e8c927cfc67f3708b91ac79df07707af26e4929 /gl/malloc.c
parent828a9720b10814c5836d03aa35af05d196c4104b (diff)
parentb0afb8fe0ff1d87165af9df61501197a06240dda (diff)
downloadmonitoring-plugins-e7dd07c8025b169b7b43b955066a7200d9cdf244.tar.gz
Merge pull request #2213 from RincewindsHat/update/gnulib
Sync with Gnulib stable-202507 code (a8ac9f9ce5)
Diffstat (limited to 'gl/malloc.c')
-rw-r--r--gl/malloc.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/gl/malloc.c b/gl/malloc.c
index 2a7867a1..5642c83c 100644
--- a/gl/malloc.c
+++ b/gl/malloc.c
@@ -1,6 +1,6 @@
1/* malloc() function that is glibc compatible. 1/* malloc() function that is glibc compatible.
2 2
3 Copyright (C) 1997-1998, 2006-2007, 2009-2024 Free Software Foundation, Inc. 3 Copyright (C) 1997-1998, 2006-2007, 2009-2025 Free Software Foundation, Inc.
4 4
5 This file is free software: you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as 6 it under the terms of the GNU Lesser General Public License as
@@ -17,28 +17,33 @@
17 17
18/* written by Jim Meyering and Bruno Haible */ 18/* written by Jim Meyering and Bruno Haible */
19 19
20/* Ensure that we call the system's malloc() below. */
20#define _GL_USE_STDLIB_ALLOC 1 21#define _GL_USE_STDLIB_ALLOC 1
21#include <config.h> 22#include <config.h>
22 23
23#include <stdlib.h> 24#include <stdlib.h>
24 25
25#include <errno.h> 26#include <errno.h>
26 27#include <stdckdint.h>
27#include "xalloc-oversized.h"
28 28
29/* Allocate an N-byte block of memory from the heap, even if N is 0. */ 29/* Allocate an N-byte block of memory from the heap, even if N is 0. */
30 30
31void * 31void *
32rpl_malloc (size_t n) 32rpl_malloc (size_t n)
33{ 33{
34#if !HAVE_MALLOC_0_NONNULL
34 if (n == 0) 35 if (n == 0)
35 n = 1; 36 n = 1;
37#endif
36 38
37 if (xalloc_oversized (n, 1)) 39#if !HAVE_MALLOC_PTRDIFF
40 ptrdiff_t signed_n;
41 if (ckd_add (&signed_n, n, 0))
38 { 42 {
39 errno = ENOMEM; 43 errno = ENOMEM;
40 return NULL; 44 return NULL;
41 } 45 }
46#endif
42 47
43 void *result = malloc (n); 48 void *result = malloc (n);
44 49