mirror of https://github.com/nodejs/node.git
src: better error message on failed Buffer malloc
PR-URL: https://github.com/nodejs/node/pull/2422 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>pull/2415/merge
parent
00bffa6c75
commit
90a2671889
|
@ -408,8 +408,10 @@ void Create(const FunctionCallbackInfo<Value>& args) {
|
|||
void* data;
|
||||
if (length > 0) {
|
||||
data = malloc(length);
|
||||
if (data == nullptr)
|
||||
return env->ThrowRangeError("invalid Buffer length");
|
||||
if (data == nullptr) {
|
||||
return env->ThrowRangeError(
|
||||
"Buffer allocation failed - process out of memory");
|
||||
}
|
||||
} else {
|
||||
data = nullptr;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue