brave / muon

[DEPRECATED] Build browsers and browser like applications with HTML, CSS, and JavaScript
https://discord.gg/TcT5tX2
MIT License
971 stars 114 forks source link

Issue 14968: NULL deref while setting the window_id for the tab_helper of new_contents #640

Closed jumde closed 6 years ago

jumde commented 6 years ago

Fix https://github.com/brave/browser-laptop/issues/14968

The issue was highlighted in the comment here - https://github.com/brave/muon/blob/4ffc7f014f0b8cc8853fb39e2efe35e30194abbe/atom/browser/api/atom_api_web_contents.cc#L792

For the source webcontents owner_window or relay will not be available if the tab is not attached. Instead we fetch the browser directly from the tab_helper to get window_id for the new_contents.

For extensions and main window the tab_helper will be null, if tab_helper is null we fallback to the original code.

Test Plan

poc.html

 <script>
  function pop (){
    open('about:blank').open('about:blank')
  }
</script>
<a href="#" onclick="pop()">Click</a>
  1. Host poc.html on a webserver
  2. Navigate to http:///poc.html and click the hyperlink.

Expected Result: No crash

Also, verify if extensions are working correctly.

Submitter Checklist:

Reviewer Checklist: