mirror of
https://github.com/gperftools/gperftools
synced 2025-01-19 21:40:58 +00:00
set ENOMEM in handle_oom
This commit is contained in:
parent
14fd551072
commit
dfd53da578
@ -1109,6 +1109,16 @@ void* handle_oom(malloc_fn retry_fn,
|
||||
void* retry_arg,
|
||||
bool from_operator,
|
||||
bool nothrow) {
|
||||
// we hit out of memory condition, usually if it happens we've
|
||||
// called sbrk or mmap and failed, and thus errno is set. But there
|
||||
// is support for setting up custom system allocator or setting up
|
||||
// page heap size limit, in which cases errno may remain
|
||||
// untouched.
|
||||
//
|
||||
// So we set errno here. C++ operator new doesn't require ENOMEM to
|
||||
// be set, but doesn't forbid it too (and often C++ oom does happen
|
||||
// with ENOMEM set).
|
||||
errno = ENOMEM;
|
||||
if (!from_operator && !tc_new_mode) {
|
||||
// we're out of memory in C library function (malloc etc) and no
|
||||
// "new mode" forced on us. Just return NULL
|
||||
|
Loading…
Reference in New Issue
Block a user