mirror of
https://github.com/freebsd/freebsd-src.git
synced 2024-12-03 14:48:57 +00:00
Always set errno to ENOMEM when returning 0 from malloc() or realloc().
Approved by: phk
This commit is contained in:
parent
be74589b43
commit
c58b5cffa1
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=48670
@ -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);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user