]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Improve MALLOC_DEBUG
authorWilco Dijkstra <wilco.dijkstra@arm.com>
Sat, 2 Aug 2025 17:18:57 +0000 (17:18 +0000)
committerWilco Dijkstra <wilco.dijkstra@arm.com>
Mon, 4 Aug 2025 17:13:55 +0000 (17:13 +0000)
malloc/malloc.c

index 2ac562506e4d877fe16da1d37209f799d3f4c7f8..415c59a8753a57e053ded9e4a0dff6c242bff9f4 100644 (file)
@@ -3460,8 +3460,6 @@ __libc_free (void *mem)
   if (__glibc_unlikely (misaligned_chunk (p)))
     return malloc_printerr_tail ("free(): invalid pointer");
 
-  check_inuse_chunk (arena_for_chunk (p), p);
-
 #if USE_TCACHE
   if (__glibc_likely (size < mp_.tcache_max_bytes && tcache != NULL))
     {
@@ -4679,6 +4677,8 @@ _int_free_merge_chunk (mstate av, mchunkptr p, INTERNAL_SIZE_T size)
 {
   mchunkptr nextchunk = chunk_at_offset(p, size);
 
+  check_inuse_chunk (av, p);
+
   /* Lightweight tests: check whether the block is already the
      top block.  */
   if (__glibc_unlikely (p == av->top))