summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authortdeval <>2004-04-12 09:25:11 +0000
committertdeval <>2004-04-12 09:25:11 +0000
commitec9c7d8912c2c0555cd92ee066e50fe4ca2acac7 (patch)
treeb780a36f620c13b5812c090c241332f0ddfec16f /src/lib
parent7787e563350e91ae14088b2b2976e845e77794f0 (diff)
downloadopenbsd-ec9c7d8912c2c0555cd92ee066e50fe4ca2acac7.tar.gz
openbsd-ec9c7d8912c2c0555cd92ee066e50fe4ca2acac7.tar.bz2
openbsd-ec9c7d8912c2c0555cd92ee066e50fe4ca2acac7.zip
Clean up malloc_active state when aborting.
This allows for safe abort handling, without tripping into false recursivity problems. Ok tedu@, deraadt@
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/libc/stdlib/malloc.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/lib/libc/stdlib/malloc.c b/src/lib/libc/stdlib/malloc.c
index f5704754a0..ffb74717e2 100644
--- a/src/lib/libc/stdlib/malloc.c
+++ b/src/lib/libc/stdlib/malloc.c
@@ -8,7 +8,7 @@
8 */ 8 */
9 9
10#if defined(LIBC_SCCS) && !defined(lint) 10#if defined(LIBC_SCCS) && !defined(lint)
11static char rcsid[] = "$OpenBSD: malloc.c,v 1.66 2004/02/19 23:20:53 tdeval Exp $"; 11static char rcsid[] = "$OpenBSD: malloc.c,v 1.67 2004/04/12 09:25:11 tdeval Exp $";
12#endif /* LIBC_SCCS and not lint */ 12#endif /* LIBC_SCCS and not lint */
13 13
14/* 14/*
@@ -228,6 +228,9 @@ void utrace(struct ut *, int);
228#define UTRACE(a,b,c) 228#define UTRACE(a,b,c)
229#endif 229#endif
230 230
231/* Status of malloc. */
232static int malloc_active;
233
231/* my last break. */ 234/* my last break. */
232static void *malloc_brk; 235static void *malloc_brk;
233 236
@@ -335,6 +338,7 @@ wrterror(char *p)
335 if (malloc_stats) 338 if (malloc_stats)
336 malloc_dump(stderr); 339 malloc_dump(stderr);
337#endif /* MALLOC_STATS */ 340#endif /* MALLOC_STATS */
341 malloc_active--;
338 abort(); 342 abort();
339} 343}
340 344
@@ -1243,8 +1247,6 @@ ifree(void *ptr)
1243 return; 1247 return;
1244} 1248}
1245 1249
1246static int malloc_active;
1247
1248/* 1250/*
1249 * Common function for handling recursion. Only 1251 * Common function for handling recursion. Only
1250 * print the error message once, to avoid making the problem 1252 * print the error message once, to avoid making the problem