summaryrefslogtreecommitdiffstats
path: root/lib/libc/stdlib
diff options
context:
space:
mode:
authortedu <tedu@openbsd.org>2003-10-02 00:02:10 +0000
committertedu <tedu@openbsd.org>2003-10-02 00:02:10 +0000
commit460b2023996872aeff5e55ed032a7fad7f22077c (patch)
treed251147177a299671108d7be3fed057397f28284 /lib/libc/stdlib
parentit turned that only adding the cardbus part was not enough to have (diff)
downloadwireguard-openbsd-460b2023996872aeff5e55ed032a7fad7f22077c.tar.xz
wireguard-openbsd-460b2023996872aeff5e55ed032a7fad7f22077c.zip
two minor fixes. set errno on recursive calls. ENOMEM suggested by marc@.
lock before setting malloc_func, not after. ok cloder@ deraadt@
Diffstat (limited to 'lib/libc/stdlib')
-rw-r--r--lib/libc/stdlib/malloc.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/lib/libc/stdlib/malloc.c b/lib/libc/stdlib/malloc.c
index 4e88f1a2a9b..b6762298a19 100644
--- a/lib/libc/stdlib/malloc.c
+++ b/lib/libc/stdlib/malloc.c
@@ -8,7 +8,7 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
-static char rcsid[] = "$OpenBSD: malloc.c,v 1.61 2003/09/30 00:22:03 tedu Exp $";
+static char rcsid[] = "$OpenBSD: malloc.c,v 1.62 2003/10/02 00:02:10 tedu Exp $";
#endif /* LIBC_SCCS and not lint */
/*
@@ -1211,12 +1211,13 @@ malloc(size_t size)
{
void *r;
- malloc_func = " in malloc():";
_MALLOC_LOCK();
+ malloc_func = " in malloc():";
if (malloc_active++) {
wrtwarning("recursive call\n");
malloc_active--;
_MALLOC_UNLOCK();
+ errno = EDEADLK;
return (NULL);
}
r = imalloc(size);
@@ -1231,12 +1232,13 @@ malloc(size_t size)
void
free(void *ptr)
{
- malloc_func = " in free():";
_MALLOC_LOCK();
+ malloc_func = " in free():";
if (malloc_active++) {
wrtwarning("recursive call\n");
malloc_active--;
_MALLOC_UNLOCK();
+ errno = EDEADLK;
return;
}
ifree(ptr);
@@ -1251,12 +1253,13 @@ realloc(void *ptr, size_t size)
{
void *r;
- malloc_func = " in realloc():";
_MALLOC_LOCK();
+ malloc_func = " in realloc():";
if (malloc_active++) {
wrtwarning("recursive call\n");
malloc_active--;
_MALLOC_UNLOCK();
+ errno = EDEADLK;
return (NULL);
}
if (ptr == NULL) {