Skip to content

Commit 5aabb6b

Browse files
authored
fix: potential crash in chrome.tabs.update() (electron#45276)
fix: potential crash in chrome.tabs.update()
1 parent 5e05dff commit 5aabb6b

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

shell/browser/extensions/api/tabs/tabs_api.cc

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -651,7 +651,16 @@ bool TabsUpdateFunction::UpdateURL(const std::string& url_string,
651651
// will stay in the omnibox - see https://crbug.com/1085779.
652652
load_params.transition_type = ui::PAGE_TRANSITION_FROM_API;
653653

654-
web_contents_->GetController().LoadURLWithParams(load_params);
654+
base::WeakPtr<content::NavigationHandle> navigation_handle =
655+
web_contents_->GetController().LoadURLWithParams(load_params);
656+
// Navigation can fail for any number of reasons at the content layer.
657+
// Unfortunately, we can't provide a detailed error message here, because
658+
// there are too many possible triggers. At least notify the extension that
659+
// the update failed.
660+
if (!navigation_handle) {
661+
*error = "Navigation rejected.";
662+
return false;
663+
}
655664

656665
DCHECK_EQ(url,
657666
web_contents_->GetController().GetPendingEntry()->GetVirtualURL());

0 commit comments

Comments
 (0)