Skip to content

Commit

Permalink
src: fix nullptr access on realm
Browse files Browse the repository at this point in the history
Adding the per-realm binding data tracking introduced a call to a realm
method when realm was potentially null. This is triggered whenever the
function is called from `ContextifyContext::New` which passes `nullptr`
as the `realm`.

PR-URL: nodejs#48802
Reviewed-By: Joyee Cheung <[email protected]>
Reviewed-By: Chengzhong Wu <[email protected]>
Reviewed-By: Mohammed Keyvanzadeh <[email protected]>
Reviewed-By: Tobias Nießen <[email protected]>
  • Loading branch information
jkrems authored and pluris committed Aug 7, 2023
1 parent 8f67ed4 commit 0e2c4c7
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/env.cc
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,7 @@ void Environment::AssignToContext(Local<v8::Context> context,
// Used to retrieve bindings
context->SetAlignedPointerInEmbedderData(
ContextEmbedderIndex::kBindingDataStoreIndex,
realm->binding_data_store());
realm != nullptr ? realm->binding_data_store() : nullptr);

// ContextifyContexts will update this to a pointer to the native object.
context->SetAlignedPointerInEmbedderData(
Expand Down

0 comments on commit 0e2c4c7

Please sign in to comment.