Skip to content

Commit

Permalink
Check variant type to be VT_DISPATCH before checking for arrays
Browse files Browse the repository at this point in the history
  • Loading branch information
jimevans committed May 8, 2018
1 parent c3bb30c commit 14a3e7b
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion cpp/iedriver/VariantUtilities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ bool VariantUtilities::VariantIsElement(VARIANT value) {
}

bool VariantUtilities::VariantIsArray(VARIANT value) {
if (value.vt != VT_DISPATCH) {
return false;
}

std::wstring type_name = GetVariantObjectTypeName(value);

// If the name is DispStaticNodeList, we can be pretty sure it's an array
Expand All @@ -97,7 +101,7 @@ bool VariantUtilities::VariantIsArray(VARIANT value) {
// Closure library.
// IMPORTANT: Using this script, user-defined objects with a length
// property defined will be seen as arrays instead of objects.
if (type_name == L"JScriptTypeInfo") {
if (type_name == L"JScriptTypeInfo" || type_name == L"") {
LOG(DEBUG) << "Result type is JScriptTypeInfo";
LPOLESTR length_property_name = L"length";
DISPID dispid_length = 0;
Expand All @@ -115,6 +119,9 @@ bool VariantUtilities::VariantIsArray(VARIANT value) {
}

bool VariantUtilities::VariantIsObject(VARIANT value) {
if (value.vt != VT_DISPATCH) {
return false;
}
std::wstring type_name = GetVariantObjectTypeName(value);
if (type_name == L"JScriptTypeInfo") {
return true;
Expand Down

0 comments on commit 14a3e7b

Please sign in to comment.