Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: remove potential double free when managing WebContents #15280

Merged
merged 2 commits into from Oct 22, 2018

Conversation

zcbenz
Copy link
Member

@zcbenz zcbenz commented Oct 19, 2018

Description of Change

When creating V8 wrapper for WebContents there is a short time that we have 2 unique_ptr pointing to the same memory.

This PR refactors the code to avoid doing that, and make our interface take unique_ptr as parameter to avoid that in future.

Checklist

  • PR description included and stakeholders cc'd
  • npm test passes
  • tests are changed or added
  • relevant documentation is changed or added
  • PR title follows semantic commit guidelines

Release Notes

Notes: Remove potential double free when managing WebContents

Chromium expects us to take ownership of WebContents in AddNewContents,
we should not create V8 wrapper in WebContentsCreated, otherwise we
would have WebContents being managed by 2 unique_ptr at the same time.
@zcbenz zcbenz requested a review from a team October 19, 2018 09:49
Copy link
Member

@deepak1556 deepak1556 left a comment

Choose a reason for hiding this comment

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

👍

// TODO(zcbenz): Make InitWithWebContents take unique_ptr.
// At the time of writing we are going through a refactoring and I don't want
// to make other people's work harder.
InitWithWebContents(owned_web_contents.release(), session->browser_context(),
Copy link
Member

Choose a reason for hiding this comment

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

When fixing this, can you also move some of the CreateForWebContents there, would simply api layer.

@ckerr ckerr merged commit cb9be09 into master Oct 22, 2018
@ckerr ckerr deleted the fix-potential-double-free branch October 22, 2018 18:02
@release-clerk
Copy link

release-clerk bot commented Oct 22, 2018

Release Notes Persisted

Remove potential double free when managing WebContents

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants