From be61486447ab447ac24892845af92489fe0b7148 Mon Sep 17 00:00:00 2001 From: Bernhard Reutner-Fischer Date: Wed, 18 Mar 2015 23:11:39 +0100 Subject: malloc-standard: Add locking to malloc_trim Closes bugzilla #4586 Signed-off-by: Bernhard Reutner-Fischer --- libc/stdlib/malloc-standard/free.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'libc/stdlib') diff --git a/libc/stdlib/malloc-standard/free.c b/libc/stdlib/malloc-standard/free.c index 39e54d635..8b7a81fca 100644 --- a/libc/stdlib/malloc-standard/free.c +++ b/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; } /* -- cgit v1.2.3