Browse Source

malloc-standard: Add locking to malloc_trim

Closes bugzilla #4586

Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
Bernhard Reutner-Fischer 9 years ago
parent
commit
be61486447
1 changed files with 5 additions and 1 deletions
  1. 5 1
      libc/stdlib/malloc-standard/free.c

+ 5 - 1
libc/stdlib/malloc-standard/free.c

@@ -104,9 +104,13 @@ static int __malloc_trim(size_t pad, mstate av)
 */
 int malloc_trim(size_t pad)
 {
+  int r;
+  __MALLOC_LOCK;
   mstate av = get_malloc_state();
   __malloc_consolidate(av);
-  return __malloc_trim(pad, av);
+  r = __malloc_trim(pad, av);
+  __MALLOC_UNLOCK;
+  return r;
 }
 
 /*