]> sourceware.org Git - glibc.git/commitdiff
mcheck Fix malloc_usable_size [BZ #22057]
authorSiddhesh Poyarekar <siddhesh@sourceware.org>
Thu, 22 Jul 2021 13:08:16 +0000 (18:38 +0530)
committerSiddhesh Poyarekar <siddhesh@sourceware.org>
Thu, 22 Jul 2021 13:08:16 +0000 (18:38 +0530)
Interpose malloc_usable_size to return the correct mcheck value for
malloc_usable_size.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Tested-by: Carlos O'Donell <carlos@redhat.com>
malloc/Makefile
malloc/malloc-debug.c
malloc/mcheck-impl.c

index 96328da247426dfd2d33f599090d140e7994c6a2..d54285192aa2c9af5e3dbb67af0864aa965b832e 100644 (file)
@@ -83,7 +83,7 @@ ifeq ($(have-GLIBC_2.23)$(build-shared),yesyes)
 # the tests expect specific internal behavior that is changed due to linking to
 # libmcheck.a.
 tests-exclude-mcheck = tst-mallocstate \
-       tst-safe-linking tst-malloc-usable \
+       tst-safe-linking \
        tst-malloc-backtrace \
        tst-malloc-fork-deadlock \
        tst-malloc-stats-cancellation \
@@ -92,8 +92,6 @@ tests-exclude-mcheck = tst-mallocstate \
        tst-malloc-thread-fail \
        tst-malloc-usable-tunables \
        tst-malloc_info \
-       tst-pvalloc-fortify \
-       tst-reallocarray \
        tst-compathooks-off tst-compathooks-on
 
 tests-mcheck = $(filter-out $(tests-exclude-mcheck), $(tests))
index 34523b0cc30ade2986ac18cb68d1b97e6bea466b..9922ef5f25d2e018fdf830e3cf80ad5db590eef2 100644 (file)
@@ -399,6 +399,8 @@ strong_alias (__debug_calloc, calloc)
 size_t
 malloc_usable_size (void *mem)
 {
+  if (__is_malloc_debug_enabled (MALLOC_MCHECK_HOOK))
+    return mcheck_usable_size (mem);
   if (__is_malloc_debug_enabled (MALLOC_CHECK_HOOK))
     return malloc_check_get_size (mem);
 
index 8857e6b179fda46b0a7095d3a321ac8278b4475b..6597a290a6e8cd21481a013fc8534717f0b9a5ec 100644 (file)
@@ -404,3 +404,9 @@ __mcheck_initialize (void (*func) (enum mcheck_status), bool in_pedantic)
   pedantic = in_pedantic;
   return 0;
 }
+
+static int
+mcheck_usable_size (struct hdr *h)
+{
+  return (h - 1)->size;
+}
This page took 0.047163 seconds and 5 git commands to generate.