Skip to content

Commit

Permalink
fix(core): LoadUntrustedContent crash protect
Browse files Browse the repository at this point in the history
  • Loading branch information
etkmao authored and wwwcg committed Oct 17, 2024
1 parent 4fb3980 commit ad58331
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions driver/js/src/modules/contextify_module.cc
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,14 @@ void ContextifyModule::LoadUntrustedContent(CallbackInfo& info, void* data) {
auto scope_wrapper = reinterpret_cast<ScopeWrapper*>(std::any_cast<void*>(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.");
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit ad58331

Please sign in to comment.