Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions shell/browser/native_window_views.cc
Original file line number Diff line number Diff line change
Expand Up @@ -521,8 +521,15 @@ void NativeWindowViews::SetWindowTransform(
#endif

void NativeWindowViews::SetContentView(views::View* view) {
if (content_view()) {
root_view_.RemoveChildView(content_view());
auto* cv = content_view();
if (cv) {
set_content_view(nullptr);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need this as set_content_view will always be called below and all it does is set content_view_?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This defends against use after free when RemoveChildViewT path triggers

focused_view_ = nullptr;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need this as focused_view_ will always be set below?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above

if (!cv->owned_by_client()) {
root_view_.RemoveChildViewT(cv);
} else {
root_view_.RemoveChildView(cv);
}
Comment on lines +528 to +532
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gostoshbs
We are almost at the tip of the tree on Electron and haven't been addressed upstream.
Can you please add a test case and send this upstream? That would avoid same issue coming back again or having merge issues.

}
set_content_view(view);
focused_view_ = view;
Expand Down
Loading