src: better error message on failed Buffer malloc
authorKarl Skomski <karl@skomski.com>
Mon, 17 Aug 2015 20:51:42 +0000 (22:51 +0200)
committerBen Noordhuis <info@bnoordhuis.nl>
Tue, 18 Aug 2015 11:51:05 +0000 (13:51 +0200)
PR-URL: https://github.com/nodejs/node/pull/2422
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
src/node_buffer.cc

index 76a7333..c8be5b5 100644 (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;
   }