mirror of
https://github.com/nodejs/node.git
synced 2026-11-27 17:52:27 -05:00
src: better error message on failed Buffer malloc
PR-URL: https://github.com/nodejs/node/pull/2422 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
This commit is contained in:
1 parent
7fe6dd8f5d
commit
34f2cfa806
1 file changed
+4
-2
+4
-2
@@ -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;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user