From 1297b0fe23fe781db011a7cae231bb691b930d63 Mon Sep 17 00:00:00 2001 From: Sergey Chernyshev Date: Thu, 25 Apr 2024 04:19:06 +0200 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 --- graal-nodejs/src/env.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/graal-nodejs/src/env.cc b/graal-nodejs/src/env.cc index 74942f51d60..1650027820a 100644 --- a/graal-nodejs/src/env.cc +++ b/graal-nodejs/src/env.cc @@ -547,7 +547,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(