Skip to content

Commit 81371b4

Browse files
committed
Adding return value checking for CoCreateInstance of IShellWindows
Fixes issue #5564.
1 parent f454a5c commit 81371b4

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

cpp/iedriver/BrowserFactory.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -494,10 +494,14 @@ bool BrowserFactory::AttachToBrowserUsingShellWindows(
494494
LOG(TRACE) << "Entering BrowserFactory::AttachToBrowserUsingShellWindows";
495495

496496
CComPtr<IShellWindows> shell_windows;
497-
shell_windows.CoCreateInstance(CLSID_ShellWindows);
497+
HRESULT hr = shell_windows.CoCreateInstance(CLSID_ShellWindows);
498+
if (FAILED(hr)) {
499+
LOGHR(WARN, hr) << "Unable to create an object using the IShellWindows interface with CoCreateInstance";
500+
return false;
501+
}
498502

499503
CComPtr<IUnknown> enumerator_unknown;
500-
HRESULT hr = shell_windows->_NewEnum(&enumerator_unknown);
504+
hr = shell_windows->_NewEnum(&enumerator_unknown);
501505
if (FAILED(hr)) {
502506
LOGHR(WARN, hr) << "Unable to get enumerator from IShellWindows interface";
503507
return false;

0 commit comments

Comments
 (0)