aboutsummaryrefslogtreecommitdiff
path: root/malloc/mcheck.c
diff options
context:
space:
mode:
Diffstat (limited to 'malloc/mcheck.c')
-rw-r--r--malloc/mcheck.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/malloc/mcheck.c b/malloc/mcheck.c
index f17bc0c0c5..971e2e52c6 100644
--- a/malloc/mcheck.c
+++ b/malloc/mcheck.c
@@ -315,6 +315,10 @@ mcheck (func)
/* These hooks may not be safely inserted if malloc is already in use. */
if (__malloc_initialized <= 0 && !mcheck_used)
{
+ /* We call malloc() once here to ensure it is initialized. */
+ void *p = malloc (0);
+ free (p);
+
old_free_hook = __free_hook;
__free_hook = freehook;
old_malloc_hook = __malloc_hook;