Skip to content

Commit f55aca6

Browse files
committed
crypto: fix memory leak in randomBytes() error path
This is the conceptual back-port of commit ec54873 from the master branch.
1 parent 255650f commit f55aca6

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

src/node_crypto.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4011,7 +4011,9 @@ void RandomBytesCheck(RandomBytesRequest* req, Local<Value> argv[2]) {
40114011
Buffer* buffer = Buffer::New(req->data_, req->size_, RandomBytesFree, NULL);
40124012
argv[0] = Local<Value>::New(Null());
40134013
argv[1] = Local<Object>::New(buffer->handle_);
4014+
req->data_ = NULL;
40144015
}
4016+
free(req->data_);
40154017
}
40164018

40174019

0 commit comments

Comments
 (0)