Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Commit

Permalink
crypto: fix memory leak in randomBytes() error path
Browse files Browse the repository at this point in the history
  • Loading branch information
bnoordhuis committed Aug 16, 2013
1 parent 9475ee4 commit ec54873
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/node_crypto.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3422,15 +3422,17 @@ void RandomBytesCheck(RandomBytesRequest* req, Local<Value> argv[2]) {
if (req->error_) {
char errmsg[256] = "Operation not supported";

if (req->error_ != (unsigned long) -1)
if (req->error_ != static_cast<unsigned long>(-1))
ERR_error_string_n(req->error_, errmsg, sizeof errmsg);

argv[0] = Exception::Error(OneByteString(node_isolate, errmsg));
argv[1] = Null(node_isolate);
} else {
argv[0] = Null(node_isolate);
argv[1] = Buffer::Use(req->data_, req->size_);
req->data_ = NULL;
}
free(req->data_);
}


Expand Down

0 comments on commit ec54873

Please sign in to comment.