From 90a267188937c9f8d522fa6095a1ff8087fa8ee0 Mon Sep 17 00:00:00 2001 From: Karl Skomski Date: Mon, 17 Aug 2015 22:51:42 +0200 Subject: [PATCH] src: better error message on failed Buffer malloc PR-URL: https://github.com/nodejs/node/pull/2422 Reviewed-By: Ben Noordhuis --- src/node_buffer.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/node_buffer.cc b/src/node_buffer.cc index 76a733311b0..c8be5b5a448 100644 --- a/src/node_buffer.cc +++ b/src/node_buffer.cc @@ -408,8 +408,10 @@ void Create(const FunctionCallbackInfo& 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; }