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: #2422
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
  • Loading branch information
skomski authored and bnoordhuis committed Aug 18, 2015
1 parent 00bffa6 commit 90a2671
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 90a2671

Please sign in to comment.