From 1222bc129dd04ee95bd29dbd6e7653e15403ca64 Mon Sep 17 00:00:00 2001 From: Jan Olaf Krems Date: Sun, 16 Jul 2023 22:18:15 +0000 Subject: [PATCH] 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 --- 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(