Skip to content

Commit

Permalink
src: better error message on failed Buffer malloc
Browse files Browse the repository at this point in the history
PR-URL: nodejs#2422
Reviewed-By: Ben Noordhuis <[email protected]>
  • Loading branch information
skomski authored and Fishrock123 committed Aug 19, 2015
1 parent 7fe6dd8 commit 34f2cfa
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/node_buffer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 34f2cfa

Please sign in to comment.