Skip to content

Commit b18a012

Browse files
codebytereMarshallOfSound
authored andcommitted
fix: On close trying to remove observer from an empty collection leads to an access violation (electron#15739) (electron#18992)
1 parent 8acf577 commit b18a012

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

atom/browser/api/atom_api_web_contents.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,9 @@ class WebContents : public mate::TrackableObject<WebContents>,
293293
observers_.AddObserver(obs);
294294
}
295295
void RemoveObserver(ExtendedWebContentsObserver* obs) {
296-
observers_.RemoveObserver(obs);
296+
// Trying to remove from an empty collection leads to an access violation
297+
if (observers_.might_have_observers())
298+
observers_.RemoveObserver(obs);
297299
}
298300

299301
bool EmitNavigationEvent(const std::string& event,

0 commit comments

Comments
 (0)