fix: On close trying to remove observer from an empty collection leads to an access violation (#15739)
This commit is contained in:
parent
e12c0dcf66
commit
b97d7e7ecd
1 changed files with 3 additions and 1 deletions
|
@ -298,6 +298,8 @@ class WebContents : public mate::TrackableObject<WebContents>,
|
||||||
observers_.AddObserver(obs);
|
observers_.AddObserver(obs);
|
||||||
}
|
}
|
||||||
void RemoveObserver(ExtendedWebContentsObserver* obs) {
|
void RemoveObserver(ExtendedWebContentsObserver* obs) {
|
||||||
|
// Trying to remove from an empty collection leads to an access violation
|
||||||
|
if (observers_.might_have_observers())
|
||||||
observers_.RemoveObserver(obs);
|
observers_.RemoveObserver(obs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue