From b97d7e7ecd6ed403cea700ab4aab0d0d20624f7f Mon Sep 17 00:00:00 2001 From: Simone Cattaneo Date: Mon, 19 Nov 2018 17:47:04 +0100 Subject: [PATCH] fix: On close trying to remove observer from an empty collection leads to an access violation (#15739) --- atom/browser/api/atom_api_web_contents.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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,