diff --git a/src/node_crypto.cc b/src/node_crypto.cc index d86a15fbfa6..f508ba17d7e 100644 --- a/src/node_crypto.cc +++ b/src/node_crypto.cc @@ -4111,14 +4111,14 @@ EIO_PBKDF2After(uv_work_t* req) { pbkdf2_req* request = (pbkdf2_req*)req->data; delete req; - Handle argv[2]; + Local argv[2]; if (request->err) { - argv[0] = Undefined(); + argv[0] = Local::New(Undefined()); argv[1] = Encode(request->key, request->keylen, BINARY); memset(request->key, 0, request->keylen); } else { argv[0] = Exception::Error(String::New("PBKDF2 error")); - argv[1] = Undefined(); + argv[1] = Local::New(Undefined()); } TryCatch try_catch; @@ -4285,9 +4285,8 @@ void RandomBytesWork(uv_work_t* work_req) { } -void RandomBytesCheck(RandomBytesRequest* req, Handle argv[2]) { - HandleScope scope; - +// don't call this function without a valid HandleScope +void RandomBytesCheck(RandomBytesRequest* req, Local argv[2]) { if (req->error_) { char errmsg[256] = "Operation not supported"; @@ -4295,13 +4294,13 @@ void RandomBytesCheck(RandomBytesRequest* req, Handle argv[2]) { ERR_error_string_n(req->error_, errmsg, sizeof errmsg); argv[0] = Exception::Error(String::New(errmsg)); - argv[1] = Null(); + argv[1] = Local::New(Null()); } else { // avoids the malloc + memcpy Buffer* buffer = Buffer::New(req->data_, req->size_, RandomBytesFree, NULL); - argv[0] = Null(); - argv[1] = buffer->handle_; + argv[0] = Local::New(Null()); + argv[1] = Local::New(buffer->handle_); } } @@ -4312,7 +4311,7 @@ void RandomBytesAfter(uv_work_t* work_req) { container_of(work_req, RandomBytesRequest, work_req_); HandleScope scope; - Handle argv[2]; + Local argv[2]; RandomBytesCheck(req, argv); TryCatch tc; @@ -4355,7 +4354,7 @@ Handle RandomBytes(const Arguments& args) { return Undefined(); } else { - Handle argv[2]; + Local argv[2]; RandomBytesWork(&req->work_req_); RandomBytesCheck(req, argv); delete req;