diff options
author | Ben Noordhuis <info@bnoordhuis.nl> | 2013-08-16 16:42:50 +0200 |
---|---|---|
committer | Ben Noordhuis <info@bnoordhuis.nl> | 2013-08-16 16:47:30 +0200 |
commit | ec548734cae52713432addacc6787b87f5c5051e (patch) | |
tree | 9fc7f7716573cce0d03fc75ddc1c337a29765db0 | |
parent | 9475ee41ad302d05c641b99cebef3e3f70b6c18f (diff) | |
download | node-ec548734cae52713432addacc6787b87f5c5051e.tar.gz |
crypto: fix memory leak in randomBytes() error path
-rw-r--r-- | src/node_crypto.cc | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/node_crypto.cc b/src/node_crypto.cc index 665010bd1..0344d207a 100644 --- a/src/node_crypto.cc +++ b/src/node_crypto.cc @@ -3422,7 +3422,7 @@ 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)); @@ -3430,7 +3430,9 @@ void RandomBytesCheck(RandomBytesRequest* req, Local<Value> argv[2]) { } else { argv[0] = Null(node_isolate); argv[1] = Buffer::Use(req->data_, req->size_); + req->data_ = NULL; } + free(req->data_); } |