aboutsummaryrefslogtreecommitdiff
path: root/lib/libc/stdlib/malloc.c
diff options
context:
space:
mode:
authorDag-Erling Smørgrav <des@FreeBSD.org>1999-07-07 19:54:08 +0000
committerDag-Erling Smørgrav <des@FreeBSD.org>1999-07-07 19:54:08 +0000
commitc58b5cffa14bfdcab1d190acb733982b3a87d5c3 (patch)
tree02df43bf5ac52ccf71c4cfa364240bec769716dd /lib/libc/stdlib/malloc.c
parentbe74589b436024765dae77c54fd50c8a37fd5484 (diff)
downloadsrc-c58b5cffa14bfdcab1d190acb733982b3a87d5c3.tar.gz
src-c58b5cffa14bfdcab1d190acb733982b3a87d5c3.zip
Always set errno to ENOMEM when returning 0 from malloc() or realloc().
Approved by: phk
Notes
Notes: svn path=/head/; revision=48670
Diffstat (limited to 'lib/libc/stdlib/malloc.c')
-rw-r--r--lib/libc/stdlib/malloc.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/libc/stdlib/malloc.c b/lib/libc/stdlib/malloc.c
index ce8769c2d172..ca18d56d64ba 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.43 1998/09/30 06:13:59 jb Exp $
+ * $Id: malloc.c,v 1.44 1999/03/28 14:16:05 phk Exp $
*
*/
@@ -1081,6 +1081,8 @@ malloc(size_t size)
THREAD_UNLOCK();
if (malloc_xmalloc && !r)
wrterror("out of memory.\n");
+ if (!r)
+ errno = ENOMEM;
return (r);
}
@@ -1133,6 +1135,8 @@ realloc(void *ptr, size_t size)
THREAD_UNLOCK();
if (malloc_xmalloc && !r)
wrterror("out of memory.\n");
+ if (!r)
+ errno = ENOMEM;
return (r);
}