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: https://github.com/nodejs/node/pull/48802
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
This commit is contained in:
Jan Olaf Krems authored and RafaelGSS committed 2023-08-15 14:34:00 -03:00
1 parent 388c7d9232
commit 409cc692db
1 file changed
+1 -1
+1 -1
View File
@@ -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(