forked from pool/glibc
38 lines
791 B
Diff
38 lines
791 B
Diff
--- malloc/hooks.c~ 2009-06-08 17:55:07.982329000 +0200
|
|
+++ malloc/hooks.c 2009-06-08 17:56:41.178045000 +0200
|
|
@@ -276,15 +276,18 @@
|
|
mchunkptr p;
|
|
|
|
if(!mem) return;
|
|
+#ifndef ATOMIC_FASTBINS
|
|
+ (void)mutex_lock(&main_arena.mutex);
|
|
+#endif
|
|
p = mem2chunk_check(mem, NULL);
|
|
if(!p) {
|
|
malloc_printerr(check_action, "free(): invalid pointer", mem);
|
|
- return;
|
|
+ goto out;
|
|
}
|
|
#if HAVE_MMAP
|
|
if (chunk_is_mmapped(p)) {
|
|
munmap_chunk(p);
|
|
- return;
|
|
+ goto out;
|
|
}
|
|
#endif
|
|
#if 0 /* Erase freed memory. */
|
|
@@ -293,8 +296,12 @@
|
|
#ifdef ATOMIC_FASTBINS
|
|
_int_free(&main_arena, p, 0);
|
|
#else
|
|
- (void)mutex_lock(&main_arena.mutex);
|
|
_int_free(&main_arena, p);
|
|
+#endif
|
|
+out:
|
|
+#ifdef ATOMIC_FASTBINS
|
|
+ ;
|
|
+#else
|
|
(void)mutex_unlock(&main_arena.mutex);
|
|
#endif
|
|
}
|