chore: avoid crash while notification removal (#43060)

* avoid crash of operation on an invalid entry while erase set iterator.

Co-authored-by: bill.shen <shenyb32768@gmail.com>

* fix notification removal crash due to the nullptr presenter

Co-authored-by: bill.shen <shenyb32768@gmail.com>

---------

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: bill.shen <shenyb32768@gmail.com>
This commit is contained in:
trop[bot] 2024-07-26 17:22:26 -04:00 committed by GitHub
parent 00785e5444
commit 3a5ddd4c78
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 8 additions and 1 deletions

View file

@ -27,6 +27,11 @@ base::WeakPtr<Notification> NotificationPresenter::CreateNotification(
}
void NotificationPresenter::RemoveNotification(Notification* notification) {
auto it = notifications_.find(notification);
if (it == notifications_.end()) {
return;
}
notifications_.erase(notification);
delete notification;
}