Skip to content

Commit 14a3e7b

Browse files
committed
Check variant type to be VT_DISPATCH before checking for arrays
1 parent c3bb30c commit 14a3e7b

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

cpp/iedriver/VariantUtilities.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,10 @@ bool VariantUtilities::VariantIsElement(VARIANT value) {
7979
}
8080

8181
bool VariantUtilities::VariantIsArray(VARIANT value) {
82+
if (value.vt != VT_DISPATCH) {
83+
return false;
84+
}
85+
8286
std::wstring type_name = GetVariantObjectTypeName(value);
8387

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

117121
bool VariantUtilities::VariantIsObject(VARIANT value) {
122+
if (value.vt != VT_DISPATCH) {
123+
return false;
124+
}
118125
std::wstring type_name = GetVariantObjectTypeName(value);
119126
if (type_name == L"JScriptTypeInfo") {
120127
return true;

0 commit comments

Comments
 (0)