summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authoralex <alex@FreeBSD.org>1998-09-19 20:55:36 +0000
committeralex <alex@FreeBSD.org>1998-09-19 20:55:36 +0000
commit2945cc62f8922148cf144d3bcb921e3645b86661 (patch)
tree56d47fdcb82031dbbda21813711bff51061a24aa /lib
parent858002dcbabfb94a990d5111ed2dd7c0fb4f8825 (diff)
downloadFreeBSD-src-2945cc62f8922148cf144d3bcb921e3645b86661.zip
FreeBSD-src-2945cc62f8922148cf144d3bcb921e3645b86661.tar.gz
Correctly back out of free if a recursive call into malloc.c is detected.
Set malloc_func *after* grabbing the thread lock. Noticed by: Simon Coggins <simon@oz.org>
Diffstat (limited to 'lib')
-rw-r--r--lib/libc/stdlib/malloc.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/lib/libc/stdlib/malloc.c b/lib/libc/stdlib/malloc.c
index 44cf8c0..13aed80 100644
--- a/lib/libc/stdlib/malloc.c
+++ b/lib/libc/stdlib/malloc.c
@@ -6,7 +6,7 @@
* this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
* ----------------------------------------------------------------------------
*
- * $Id: malloc.c,v 1.38 1998/06/09 08:30:32 jb Exp $
+ * $Id: malloc.c,v 1.39 1998/06/18 09:13:16 peter Exp $
*
*/
@@ -1059,8 +1059,8 @@ malloc(size_t size)
{
register void *r;
- malloc_func = " in malloc():";
THREAD_LOCK();
+ malloc_func = " in malloc():";
if (malloc_active++) {
wrtwarning("recursive call.\n");
malloc_active--;
@@ -1083,15 +1083,14 @@ malloc(size_t size)
void
free(void *ptr)
{
- malloc_func = " in free():";
THREAD_LOCK();
+ malloc_func = " in free():";
if (malloc_active++) {
wrtwarning("recursive call.\n");
- malloc_active--;
- return;
+ } else {
+ ifree(ptr);
+ UTRACE(ptr, 0, 0);
}
- ifree(ptr);
- UTRACE(ptr, 0, 0);
malloc_active--;
THREAD_UNLOCK();
return;
@@ -1102,8 +1101,8 @@ realloc(void *ptr, size_t size)
{
register void *r;
- malloc_func = " in realloc():";
THREAD_LOCK();
+ malloc_func = " in realloc():";
if (malloc_active++) {
wrtwarning("recursive call.\n");
malloc_active--;
OpenPOWER on IntegriCloud