From 33b52afd8322869c7a6481b4ef068e6fe517ceb4 Mon Sep 17 00:00:00 2001 From: etkmao Date: Thu, 17 Oct 2024 19:00:02 +0800 Subject: [PATCH] fix(core): LoadUntrustedContent crash protect --- driver/js/src/modules/contextify_module.cc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/driver/js/src/modules/contextify_module.cc b/driver/js/src/modules/contextify_module.cc index a0767dfdc7c..b45b830883b 100644 --- a/driver/js/src/modules/contextify_module.cc +++ b/driver/js/src/modules/contextify_module.cc @@ -100,8 +100,14 @@ void ContextifyModule::LoadUntrustedContent(CallbackInfo& info, void* data) { auto scope_wrapper = reinterpret_cast(std::any_cast(info.GetSlot())); auto scope = scope_wrapper->scope.lock(); FOOTSTONE_CHECK(scope); + if (!scope) { + return; + } auto context = scope->GetContext(); FOOTSTONE_CHECK(context); + if (!context) { + return; + } string_view uri; if (!context->GetValueString(info[0], &uri)) { info.GetExceptionValue()->Set(context, "The first argument must be non-empty string."); @@ -207,6 +213,9 @@ void ContextifyModule::LoadUntrustedContent(CallbackInfo& info, void* data) { auto loader = scope->GetUriLoader().lock(); FOOTSTONE_CHECK(loader); + if (!loader) { + return; + } loader->RequestUntrustedContent(uri, {}, cb); info.GetReturnValue()->SetUndefined();