diff --git a/shell/browser/notifications/notification.cc b/shell/browser/notifications/notification.cc index 40b5f846fd..9dae5fc56b 100644 --- a/shell/browser/notifications/notification.cc +++ b/shell/browser/notifications/notification.cc @@ -46,7 +46,9 @@ void Notification::NotificationFailed(const std::string& error) { void Notification::Remove() {} void Notification::Destroy() { - presenter()->RemoveNotification(this); + if (presenter()) { + presenter()->RemoveNotification(this); + } } } // namespace electron diff --git a/shell/browser/notifications/notification_presenter.cc b/shell/browser/notifications/notification_presenter.cc index 4aef716a72..0bfb5c049c 100644 --- a/shell/browser/notifications/notification_presenter.cc +++ b/shell/browser/notifications/notification_presenter.cc @@ -27,6 +27,11 @@ base::WeakPtr NotificationPresenter::CreateNotification( } void NotificationPresenter::RemoveNotification(Notification* notification) { + auto it = notifications_.find(notification); + if (it == notifications_.end()) { + return; + } + notifications_.erase(notification); delete notification; }