Skip to content

Commit bdc4787

Browse files
Mike Bellewjimevans
Mike Bellew
authored andcommitted
Fixed null pointer exception when managed element is not found
The command_executor has a chance to return an error code of ENOSUCHELEMENT. This leaves the element_wrapper object equal to null. Which ends up throwing an exception on the next like of code when it tries to use the element. This in turn causes a crash in IEDriver and it shuts down Signed-off-by: Jim Evans <james.h.evans.jr@gmail.com>
1 parent 6b4dfc6 commit bdc4787

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

cpp/iedriver/Script.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,13 @@ int Script::SetAsyncScriptElementArgument(HWND async_executor_handle,
514514
ElementInfo* info = new ElementInfo;
515515
info->element_id = element_id;
516516
ElementHandle element_wrapper;
517-
int return_code = command_executor.GetManagedElement(element_id, &element_wrapper);
517+
int return_code = command_executor.GetManagedElement(element_id,
518+
&element_wrapper);
519+
if (return_code != WD_SUCCESS) {
520+
LOG(WARN) << "Element requested with id " << element_id
521+
<< " does not exist.";
522+
return return_code;
523+
}
518524
HRESULT hr = ::CoMarshalInterThreadInterfaceInStream(IID_IHTMLElement,
519525
element_wrapper->element(),
520526
&info->element_stream);

0 commit comments

Comments
 (0)