From 409cc692db26b1552a310ddb57f4e26c547abf71 Mon Sep 17 00:00:00 2001 From: Jan Olaf Krems Date: Tue, 18 Jul 2023 15:28:19 -0700 Subject: [PATCH] src: fix nullptr access on realm MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-By: Chengzhong Wu Reviewed-By: Mohammed Keyvanzadeh Reviewed-By: Tobias Nießen --- src/env.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/env.cc b/src/env.cc index 56f4344d9e1b5d..64b8fa6e34cc28 100644 --- a/src/env.cc +++ b/src/env.cc @@ -575,7 +575,7 @@ void Environment::AssignToContext(Local 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(