[MSGINA] Prevent an infinite loop in ShellDimScreen. CORE-12028
authorMark Jansen <mark.jansen@reactos.org>
Sat, 24 Sep 2016 14:15:23 +0000 (14:15 +0000)
committerMark Jansen <mark.jansen@reactos.org>
Sat, 24 Sep 2016 14:15:23 +0000 (14:15 +0000)
svn path=/trunk/; revision=72794

reactos/dll/win32/msgina/dimmedwindow.cpp

index e3df825..0a3abad 100644 (file)
@@ -104,7 +104,7 @@ public:
     {
         MSG msg;
 
     {
         MSG msg;
 
-        while (!IsWindowVisible(m_hwnd))
+        while (!IsWindowVisible(m_hwnd) && IsWindow(m_hwnd))
         {
             while (::PeekMessage(&msg, m_hwnd, 0, 0, PM_REMOVE))
             {
         {
             while (::PeekMessage(&msg, m_hwnd, 0, 0, PM_REMOVE))
             {
@@ -261,6 +261,15 @@ ShellDimScreen(void** pUnknown, HWND* hWindow)
 
     pWindow->WaitForInit();
 
 
     pWindow->WaitForInit();
 
+    if (!IsWindow(pWindow->Wnd()))
+    {
+        refcount = pWindow->AddRef();
+        while (refcount)
+            refcount = pWindow->Release();
+
+        return E_FAIL;
+    }
+
     _SEH2_TRY
     {
         hr = pWindow->QueryInterface(IID_IUnknown, pUnknown);
     _SEH2_TRY
     {
         hr = pWindow->QueryInterface(IID_IUnknown, pUnknown);