Bug 1726696 - Use SafeElementAt to prevent crash in nsMessengerWinIntegration.cpp. r=mkmelin

Differential Revision: https://phabricator.services.mozilla.com/D127025

--HG--
extra : amend_source : 0f8c767257797ad70d07aede3e900ebd75dc8fff
This commit is contained in:
Ping Chen 2021-09-30 13:00:48 +03:00
Родитель 3d24d60619
Коммит 524595ea49
1 изменённых файлов: 7 добавлений и 3 удалений

Просмотреть файл

@ -139,10 +139,14 @@ LRESULT CALLBACK nsMessengerWinIntegration::IconWindowProc(HWND msgWindow,
// Bring the minimized windows to the front.
for (uint32_t i = 0; i < sHiddenWindows.Length(); i++) {
sHiddenWindows[i]->SetVisibility(true);
auto window = sHiddenWindows.SafeElementAt(i);
if (!window) {
continue;
}
window->SetVisibility(true);
nsCOMPtr<nsIWidget> widget;
sHiddenWindows[i]->GetMainWidget(getter_AddRefs(widget));
window->GetMainWidget(getter_AddRefs(widget));
if (!widget) {
continue;
}
@ -153,7 +157,7 @@ LRESULT CALLBACK nsMessengerWinIntegration::IconWindowProc(HWND msgWindow,
nsCOMPtr<nsIObserverService> obs =
mozilla::services::GetObserverService();
obs->NotifyObservers(sHiddenWindows[i], "window-restored-from-tray", 0);
obs->NotifyObservers(window, "window-restored-from-tray", 0);
}
sHiddenWindows.Clear();