diff --git a/widget/src/windows/WinTaskbar.cpp b/widget/src/windows/WinTaskbar.cpp index c5bc9a2194c2..1bfaf87af548 100644 --- a/widget/src/windows/WinTaskbar.cpp +++ b/widget/src/windows/WinTaskbar.cpp @@ -247,6 +247,9 @@ WinTaskbar::CreateTaskbarTabPreview(nsIDocShell *shell, nsITaskbarPreviewControl HWND toplevelHWND = ::GetAncestor(GetHWNDFromDocShell(shell), GA_ROOT); + if (!toplevelHWND) + return NS_ERROR_INVALID_ARG; + nsRefPtr preview(new TaskbarTabPreview(mTaskbar, controller, toplevelHWND, shell)); if (!preview) return NS_ERROR_OUT_OF_MEMORY; @@ -265,6 +268,9 @@ WinTaskbar::GetTaskbarWindowPreview(nsIDocShell *shell, nsITaskbarWindowPreview HWND toplevelHWND = ::GetAncestor(GetHWNDFromDocShell(shell), GA_ROOT); + if (!toplevelHWND) + return NS_ERROR_INVALID_ARG; + nsWindow *window = nsWindow::GetNSWindowPtr(toplevelHWND); if (!window)