diff --git a/atom/browser/api/atom_api_web_contents.h b/atom/browser/api/atom_api_web_contents.h index 837ca5bbba87..c1535e9e813b 100644 --- a/atom/browser/api/atom_api_web_contents.h +++ b/atom/browser/api/atom_api_web_contents.h @@ -298,7 +298,9 @@ class WebContents : public mate::TrackableObject, 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,