From 14a3e7b3eb8a3e057f990966764a3849da31424c Mon Sep 17 00:00:00 2001 From: Jim Evans Date: Tue, 8 May 2018 09:02:08 -0700 Subject: [PATCH] Check variant type to be VT_DISPATCH before checking for arrays --- cpp/iedriver/VariantUtilities.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/cpp/iedriver/VariantUtilities.cpp b/cpp/iedriver/VariantUtilities.cpp index af99c63e97d65..86b9320b2d4d6 100644 --- a/cpp/iedriver/VariantUtilities.cpp +++ b/cpp/iedriver/VariantUtilities.cpp @@ -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 @@ -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; @@ -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;