Bug 1569756: Check for S_FALSE after calling IShellWindows::FindWindowSW; r=jmathies a=jcristau
authorAaron Klotz <aklotz@mozilla.com>
Wed, 31 Jul 2019 15:31:07 +0000
changeset 537282 02d9056ba76c565c57334ae0df1246d52823cc43
parent 537281 e635e759e439d595ef59d3aa9befbbe8da0fcfb6
child 537283 ceed8b8a562b3cfba72f29a1afc36469ea0c5c77
push id2122
push userarchaeopteryx@coole-files.de
push dateWed, 07 Aug 2019 14:22:14 +0000
treeherdermozilla-release@02d9056ba76c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjmathies, jcristau
bugs1569756
milestone68.0.2
Bug 1569756: Check for S_FALSE after calling IShellWindows::FindWindowSW; r=jmathies a=jcristau `IShellWindows::FindWindowSW` may return the dreaded `S_FALSE`, so we need to ensure that we're handling that. I checked the remaining functions called by this code and none of the others do this; this is the only call site that requires the check. I'm not sure why we're seeing this error code. I added an explicit cast to ensure that `CSIDL_DESKTOP` is being interpreted as an `int`, though I doubt that this actually makes any difference. Differential Revision: https://phabricator.services.mozilla.com/D39799
widget/windows/ShellHeaderOnlyUtils.h
--- a/widget/windows/ShellHeaderOnlyUtils.h
+++ b/widget/windows/ShellHeaderOnlyUtils.h
@@ -56,27 +56,32 @@ inline LauncherVoidResult ShellExecuteBy
   HRESULT hr = ::CoCreateInstance(
       CLSID_ShellWindows, nullptr, CLSCTX_INPROC_SERVER | CLSCTX_LOCAL_SERVER,
       IID_IShellWindows, getter_AddRefs(shellWindows));
   if (FAILED(hr)) {
     return LAUNCHER_ERROR_FROM_HRESULT(hr);
   }
 
   // 1. Find the shell view for the desktop.
-  _variant_t loc(CSIDL_DESKTOP);
+  _variant_t loc(int(CSIDL_DESKTOP));
   _variant_t empty;
   long hwnd;
   RefPtr<IDispatch> dispDesktop;
   hr = shellWindows->FindWindowSW(&loc, &empty, SWC_DESKTOP, &hwnd,
                                   SWFO_NEEDDISPATCH,
                                   getter_AddRefs(dispDesktop));
   if (FAILED(hr)) {
     return LAUNCHER_ERROR_FROM_HRESULT(hr);
   }
 
+  if (hr == S_FALSE) {
+    // The call succeeded but the window was not found.
+    return LAUNCHER_ERROR_FROM_WIN32(ERROR_NOT_FOUND);
+  }
+
   RefPtr<IServiceProvider> servProv;
   hr = dispDesktop->QueryInterface(IID_IServiceProvider,
                                    getter_AddRefs(servProv));
   if (FAILED(hr)) {
     return LAUNCHER_ERROR_FROM_HRESULT(hr);
   }
 
   RefPtr<IShellBrowser> browser;