mirror of https://github.com/nodejs/node.git
crypto: root JS objects in HandleScope with Local<>
parent
f86359cc3f
commit
9eacf93928
|
@ -4111,14 +4111,14 @@ EIO_PBKDF2After(uv_work_t* req) {
|
|||
pbkdf2_req* request = (pbkdf2_req*)req->data;
|
||||
delete req;
|
||||
|
||||
Handle<Value> argv[2];
|
||||
Local<Value> argv[2];
|
||||
if (request->err) {
|
||||
argv[0] = Undefined();
|
||||
argv[0] = Local<Value>::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<Value>::New(Undefined());
|
||||
}
|
||||
|
||||
TryCatch try_catch;
|
||||
|
@ -4285,9 +4285,8 @@ void RandomBytesWork(uv_work_t* work_req) {
|
|||
}
|
||||
|
||||
|
||||
void RandomBytesCheck(RandomBytesRequest* req, Handle<Value> argv[2]) {
|
||||
HandleScope scope;
|
||||
|
||||
// don't call this function without a valid HandleScope
|
||||
void RandomBytesCheck(RandomBytesRequest* req, Local<Value> argv[2]) {
|
||||
if (req->error_) {
|
||||
char errmsg[256] = "Operation not supported";
|
||||
|
||||
|
@ -4295,13 +4294,13 @@ void RandomBytesCheck(RandomBytesRequest* req, Handle<Value> argv[2]) {
|
|||
ERR_error_string_n(req->error_, errmsg, sizeof errmsg);
|
||||
|
||||
argv[0] = Exception::Error(String::New(errmsg));
|
||||
argv[1] = Null();
|
||||
argv[1] = Local<Value>::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<Value>::New(Null());
|
||||
argv[1] = Local<Object>::New(buffer->handle_);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4312,7 +4311,7 @@ void RandomBytesAfter(uv_work_t* work_req) {
|
|||
container_of(work_req, RandomBytesRequest, work_req_);
|
||||
|
||||
HandleScope scope;
|
||||
Handle<Value> argv[2];
|
||||
Local<Value> argv[2];
|
||||
RandomBytesCheck(req, argv);
|
||||
|
||||
TryCatch tc;
|
||||
|
@ -4355,7 +4354,7 @@ Handle<Value> RandomBytes(const Arguments& args) {
|
|||
return Undefined();
|
||||
}
|
||||
else {
|
||||
Handle<Value> argv[2];
|
||||
Local<Value> argv[2];
|
||||
RandomBytesWork<generator>(&req->work_req_);
|
||||
RandomBytesCheck(req, argv);
|
||||
delete req;
|
||||
|
|
Loading…
Reference in New Issue