Skip to content

Commit dbf5198

Browse files
committed
crypto: change segmentation faults to CHECKs
Fixes: nodejs#14519
1 parent 77ca3cb commit dbf5198

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

src/node_crypto.cc

+12-5
Original file line numberDiff line numberDiff line change
@@ -5424,8 +5424,11 @@ void PBKDF2(const FunctionCallbackInfo<Value>& args) {
54245424
if (args[5]->IsFunction()) {
54255425
obj->Set(env->ondone_string(), args[5]);
54265426

5427-
if (env->in_domain())
5428-
obj->Set(env->domain_string(), env->domain_array()->Get(0));
5427+
if (env->in_domain()) {
5428+
obj->Set(env->domain_string(),
5429+
env->domain_array()->Get(env->context(), 0).ToLocalChecked());
5430+
}
5431+
54295432
uv_queue_work(env->event_loop(),
54305433
req->work_req(),
54315434
PBKDF2Request::Work,
@@ -5627,8 +5630,11 @@ void RandomBytes(const FunctionCallbackInfo<Value>& args) {
56275630
if (args[1]->IsFunction()) {
56285631
obj->Set(env->ondone_string(), args[1]);
56295632

5630-
if (env->in_domain())
5631-
obj->Set(env->domain_string(), env->domain_array()->Get(0));
5633+
if (env->in_domain()) {
5634+
obj->Set(env->domain_string(),
5635+
env->domain_array()->Get(env->context(), 0).ToLocalChecked());
5636+
}
5637+
56325638
uv_queue_work(env->event_loop(),
56335639
req->work_req(),
56345640
RandomBytesWork,
@@ -5673,7 +5679,8 @@ void RandomBytesBuffer(const FunctionCallbackInfo<Value>& args) {
56735679
if (env->in_domain()) {
56745680
obj->Set(env->context(),
56755681
env->domain_string(),
5676-
env->domain_array()->Get(0)).FromJust();
5682+
env->domain_array()->Get(env->context(), 0).ToLocalChecked())
5683+
.FromJust();
56775684
}
56785685

56795686
uv_queue_work(env->event_loop(),

0 commit comments

Comments
 (0)