summaryrefslogtreecommitdiff
path: root/lib/libc/stdlib/malloc.c
diff options
context:
space:
mode:
authorOtto Moerbeek <otto@cvs.openbsd.org>2011-05-20 20:02:09 +0000
committerOtto Moerbeek <otto@cvs.openbsd.org>2011-05-20 20:02:09 +0000
commitde2d9c98cc6d459f97916f6cd8b7d08794a8476b (patch)
treee25c7de4e6557334fae4d684ad86496e5436207c /lib/libc/stdlib/malloc.c
parentdf91a08b9c7d235816b5357472894f3b589dd521 (diff)
save errno dance in wrterror() and malloc_dump(); prompted by and ok deraadt@
Diffstat (limited to 'lib/libc/stdlib/malloc.c')
-rw-r--r--lib/libc/stdlib/malloc.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/libc/stdlib/malloc.c b/lib/libc/stdlib/malloc.c
index 8ab9f355e90..bdc6ca69d3d 100644
--- a/lib/libc/stdlib/malloc.c
+++ b/lib/libc/stdlib/malloc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: malloc.c,v 1.136 2011/05/18 18:09:37 otto Exp $ */
+/* $OpenBSD: malloc.c,v 1.137 2011/05/20 20:02:08 otto Exp $ */
/*
* Copyright (c) 2008 Otto Moerbeek <otto@drijf.net>
*
@@ -236,6 +236,7 @@ wrterror(char *msg, void *p)
char *q = " error: ";
struct iovec iov[6];
char buf[20];
+ int saved_errno = errno;
iov[0].iov_base = __progname;
iov[0].iov_len = strlen(__progname);
@@ -260,7 +261,8 @@ wrterror(char *msg, void *p)
if (mopts.malloc_stats)
malloc_dump(STDERR_FILENO);
#endif /* MALLOC_STATS */
- //malloc_active--;
+
+ errno = saved_errno;
if (mopts.malloc_abort)
abort();
}
@@ -1620,6 +1622,7 @@ malloc_dump(int fd)
int i;
void *p;
struct region_info *r;
+ int saved_errno = errno;
for (i = 0; i <= MALLOC_DELAYED_CHUNKS; i++) {
p = g_pool->delayed_chunks[i];
@@ -1634,6 +1637,7 @@ malloc_dump(int fd)
/* XXX leak when run multiple times */
RB_INIT(&leakhead);
malloc_dump1(fd, g_pool);
+ errno = saved_errno;
}
static void