fix: crash with creating OffScreenWebContentsView (#42940)

On the Mac platform, OffScreenWebContentsView uses Automatic Reference
Counting (ARC) to handle the lifecycle of offScreenView_. However, this
private member variable is not initialized and its value is undefined.
In some cases, it is initialized to a garbage value, which may cause ARC
to release the value incorrectly, resulting in a crash.

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Jinli Wu <wujinli@bytedance.com>
This commit is contained in:
trop[bot] 2024-07-17 09:10:23 -05:00 committed by GitHub
parent e69329bd9c
commit 8ed34bf203
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -109,7 +109,7 @@ class OffScreenWebContentsView : public content::WebContentsView,
raw_ptr<content::WebContents> web_contents_ = nullptr;
#if BUILDFLAG(IS_MAC)
RAW_PTR_EXCLUSION OffScreenView* offScreenView_;
RAW_PTR_EXCLUSION OffScreenView* offScreenView_ = nullptr;
#endif
};