fix: dangling raw_ptr ElectronBrowserContext::extension_system_ (#42813)

The extension system is freed by the DestroyBrowserContextServices()
call in the destructor, so we need to zero out the pointer to avoid
a dangling raw_ptr error.

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Charles Kerr <charles@charleskerr.com>
This commit is contained in:
trop[bot] 2024-07-09 11:03:45 +02:00 committed by GitHub
parent 7353fa88cd
commit 650b8e6777
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -310,6 +310,10 @@ ElectronBrowserContext::ElectronBrowserContext(
ElectronBrowserContext::~ElectronBrowserContext() { ElectronBrowserContext::~ElectronBrowserContext() {
DCHECK_CURRENTLY_ON(BrowserThread::UI); DCHECK_CURRENTLY_ON(BrowserThread::UI);
NotifyWillBeDestroyed(); NotifyWillBeDestroyed();
// the DestroyBrowserContextServices() call below frees this.
extension_system_ = nullptr;
// Notify any keyed services of browser context destruction. // Notify any keyed services of browser context destruction.
BrowserContextDependencyManager::GetInstance()->DestroyBrowserContextServices( BrowserContextDependencyManager::GetInstance()->DestroyBrowserContextServices(
this); this);