fix: On close trying to remove observer from an empty collection leads to an access violation (#15739)

This commit is contained in:
Simone Cattaneo 2018-11-19 17:47:04 +01:00 committed by John Kleinschmidt
parent e12c0dcf66
commit b97d7e7ecd

View file

@ -298,6 +298,8 @@ class WebContents : public mate::TrackableObject<WebContents>,
observers_.AddObserver(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);
}