Skip to content

Commit ec54873

Browse files
committed
crypto: fix memory leak in randomBytes() error path
1 parent 9475ee4 commit ec54873

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

src/node_crypto.cc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3422,15 +3422,17 @@ void RandomBytesCheck(RandomBytesRequest* req, Local<Value> argv[2]) {
34223422
if (req->error_) {
34233423
char errmsg[256] = "Operation not supported";
34243424

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

34283428
argv[0] = Exception::Error(OneByteString(node_isolate, errmsg));
34293429
argv[1] = Null(node_isolate);
34303430
} else {
34313431
argv[0] = Null(node_isolate);
34323432
argv[1] = Buffer::Use(req->data_, req->size_);
3433+
req->data_ = NULL;
34333434
}
3435+
free(req->data_);
34343436
}
34353437

34363438

0 commit comments

Comments
 (0)