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,7 +298,9 @@ class WebContents : public mate::TrackableObject<WebContents>,
observers_.AddObserver(obs);
}
void RemoveObserver(ExtendedWebContentsObserver* obs) {
observers_.RemoveObserver(obs);
// Trying to remove from an empty collection leads to an access violation
if (observers_.might_have_observers())
observers_.RemoveObserver(obs);
}
bool EmitNavigationEvent(const std::string& event,