aboutsummaryrefslogtreecommitdiffstats
path: root/src/gmalloc.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/gmalloc.c')
-rw-r--r--src/gmalloc.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/gmalloc.c b/src/gmalloc.c
index 97ab76561f9..99cb967e539 100644
--- a/src/gmalloc.c
+++ b/src/gmalloc.c
@@ -203,7 +203,8 @@ extern size_t _bytes_free;
203 203
204/* Internal versions of `malloc', `realloc', and `free' 204/* Internal versions of `malloc', `realloc', and `free'
205 used when these functions need to call each other. 205 used when these functions need to call each other.
206 They are the same but don't call the hooks. */ 206 They are the same but don't call the hooks
207 and don't bound the resulting pointers. */
207extern void *_malloc_internal (size_t); 208extern void *_malloc_internal (size_t);
208extern void *_realloc_internal (void *, size_t); 209extern void *_realloc_internal (void *, size_t);
209extern void _free_internal (void *); 210extern void _free_internal (void *);
@@ -921,7 +922,8 @@ malloc (size_t size)
921 among multiple threads. We just leave it for compatibility with 922 among multiple threads. We just leave it for compatibility with
922 glibc malloc (i.e., assignments to gmalloc_hook) for now. */ 923 glibc malloc (i.e., assignments to gmalloc_hook) for now. */
923 hook = gmalloc_hook; 924 hook = gmalloc_hook;
924 return (hook != NULL ? *hook : _malloc_internal) (size); 925 void *result = (hook ? hook : _malloc_internal) (size);
926 return ptr_bounds_clip (result, size);
925} 927}
926 928
927#if !(defined (_LIBC) || defined (HYBRID_MALLOC)) 929#if !(defined (_LIBC) || defined (HYBRID_MALLOC))
@@ -1434,7 +1436,8 @@ realloc (void *ptr, size_t size)
1434 return NULL; 1436 return NULL;
1435 1437
1436 hook = grealloc_hook; 1438 hook = grealloc_hook;
1437 return (hook != NULL ? *hook : _realloc_internal) (ptr, size); 1439 void *result = (hook ? hook : _realloc_internal) (ptr, size);
1440 return ptr_bounds_clip (result, size);
1438} 1441}
1439/* Copyright (C) 1991, 1992, 1994 Free Software Foundation, Inc. 1442/* Copyright (C) 1991, 1992, 1994 Free Software Foundation, Inc.
1440 1443
@@ -1608,6 +1611,7 @@ aligned_alloc (size_t alignment, size_t size)
1608 { 1611 {
1609 l->exact = result; 1612 l->exact = result;
1610 result = l->aligned = (char *) result + adj; 1613 result = l->aligned = (char *) result + adj;
1614 result = ptr_bounds_clip (result, size);
1611 } 1615 }
1612 UNLOCK_ALIGNED_BLOCKS (); 1616 UNLOCK_ALIGNED_BLOCKS ();
1613 if (l == NULL) 1617 if (l == NULL)