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:
Karl Skomski authored and Jeremiah Senkpiel committed 2015-08-19 11:39:28 -04:00
1 parent 7fe6dd8f5d
commit 34f2cfa806
1 file changed
+4 -2
+4 -2
View File
@@ -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;
}