Skip to content

Commit 34f2cfa

Browse files
skomskiFishrock123
authored andcommitted
src: better error message on failed Buffer malloc
PR-URL: #2422 Reviewed-By: Ben Noordhuis <[email protected]>
1 parent 7fe6dd8 commit 34f2cfa

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/node_buffer.cc

+4-2
Original file line numberDiff line numberDiff line change
@@ -408,8 +408,10 @@ void Create(const FunctionCallbackInfo<Value>& args) {
408408
void* data;
409409
if (length > 0) {
410410
data = malloc(length);
411-
if (data == nullptr)
412-
return env->ThrowRangeError("invalid Buffer length");
411+
if (data == nullptr) {
412+
return env->ThrowRangeError(
413+
"Buffer allocation failed - process out of memory");
414+
}
413415
} else {
414416
data = nullptr;
415417
}

0 commit comments

Comments
 (0)