Skip to content

Commit f5384c3

Browse files
jkremstargos
authored andcommitted
src: fix nullptr access on realm
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: #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]>
1 parent 629132d commit f5384c3

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/env.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,7 @@ void Environment::AssignToContext(Local<v8::Context> context,
547547
// Used to retrieve bindings
548548
context->SetAlignedPointerInEmbedderData(
549549
ContextEmbedderIndex::kBindingDataStoreIndex,
550-
realm->binding_data_store());
550+
realm != nullptr ? realm->binding_data_store() : nullptr);
551551

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

0 commit comments

Comments
 (0)