Rémi Bernon : wbemprox: Set variant type to VT_NULL if BSTR is NULL.

Alexandre Julliard julliard at winehq.org
Wed Sep 30 14:35:30 CDT 2020


Module: wine
Branch: master
Commit: 4b9d3909b841c1ca919e25a37838c1cd9b3445f5
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=4b9d3909b841c1ca919e25a37838c1cd9b3445f5

Author: Rémi Bernon <rbernon at codeweavers.com>
Date:   Wed Sep 30 12:37:39 2020 +0200

wbemprox: Set variant type to VT_NULL if BSTR is NULL.

Mafia III launcher crashes when querying video controllers when it
passes the NULL __PATH value through COM marshalling.

Signed-off-by: Rémi Bernon <rbernon at codeweavers.com>
Signed-off-by: Hans Leidekker <hans at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/wbemprox/query.c       | 12 ++++++++----
 dlls/wbemprox/tests/query.c | 32 ++++++++++++++++++++++++++++++++
 2 files changed, 40 insertions(+), 4 deletions(-)

diff --git a/dlls/wbemprox/query.c b/dlls/wbemprox/query.c
index 6ac5ad5b77..525381d88d 100644
--- a/dlls/wbemprox/query.c
+++ b/dlls/wbemprox/query.c
@@ -946,22 +946,24 @@ static HRESULT get_system_propval( const struct view *view, UINT table_index, UI
         if (type) *type = CIM_SINT32;
         return S_OK;
     }
-    else if (!wcsicmp( name, L"__NAMESPACE" ))
+    if (!wcsicmp( name, L"__NAMESPACE" ))
     {
         if (ret)
         {
             V_VT( ret ) = VT_BSTR;
             V_BSTR( ret ) = view->proplist ? NULL : build_namespace();
+            if (!V_BSTR( ret )) V_VT( ret ) = VT_NULL;
         }
         if (type) *type = CIM_STRING;
         return S_OK;
     }
-    else if (!wcsicmp( name, L"__PATH" ))
+    if (!wcsicmp( name, L"__PATH" ))
     {
         if (ret)
         {
             V_VT( ret ) = VT_BSTR;
             V_BSTR( ret ) = build_path( view, table_index, result_index, name );
+            if (!V_BSTR( ret )) V_VT( ret ) = VT_NULL;
         }
         if (type) *type = CIM_STRING;
         return S_OK;
@@ -976,22 +978,24 @@ static HRESULT get_system_propval( const struct view *view, UINT table_index, UI
         if (type) *type = CIM_SINT32;
         return S_OK;
     }
-    else if (!wcsicmp( name, L"__RELPATH" ))
+    if (!wcsicmp( name, L"__RELPATH" ))
     {
         if (ret)
         {
             V_VT( ret ) = VT_BSTR;
             V_BSTR( ret ) = build_relpath( view, table_index, result_index, name );
+            if (!V_BSTR( ret )) V_VT( ret ) = VT_NULL;
         }
         if (type) *type = CIM_STRING;
         return S_OK;
     }
-    else if (!wcsicmp( name, L"__SERVER" ))
+    if (!wcsicmp( name, L"__SERVER" ))
     {
         if (ret)
         {
             V_VT( ret ) = VT_BSTR;
             V_BSTR( ret ) = view->proplist ? NULL : build_servername();
+            if (!V_BSTR( ret )) V_VT( ret ) = VT_NULL;
         }
         if (type) *type = CIM_STRING;
         return S_OK;
diff --git a/dlls/wbemprox/tests/query.c b/dlls/wbemprox/tests/query.c
index 74fdfaa9bc..d1ce42d64c 100644
--- a/dlls/wbemprox/tests/query.c
+++ b/dlls/wbemprox/tests/query.c
@@ -1414,6 +1414,13 @@ static void test_Win32_VideoController( IWbemServices *services )
         hr = IEnumWbemClassObject_Next( result, 10000, 1, &obj, &count );
         if (hr != S_OK) break;
 
+        check_property( obj, L"__CLASS", VT_BSTR, CIM_STRING );
+        check_property( obj, L"__GENUS", VT_I4, CIM_SINT32 );
+        check_property( obj, L"__NAMESPACE", VT_BSTR, CIM_STRING );
+        check_property( obj, L"__PATH", VT_BSTR, CIM_STRING );
+        check_property( obj, L"__PROPERTY_COUNT", VT_I4, CIM_SINT32 );
+        check_property( obj, L"__RELPATH", VT_BSTR, CIM_STRING );
+        check_property( obj, L"__SERVER", VT_BSTR, CIM_STRING );
         check_property( obj, L"AdapterCompatibility", VT_BSTR, CIM_STRING );
         check_property( obj, L"Availability", VT_I4, CIM_UINT16 );
         check_property( obj, L"ConfigManagerErrorCode", VT_I4, CIM_UINT32 );
@@ -1432,6 +1439,31 @@ static void test_Win32_VideoController( IWbemServices *services )
         IWbemClassObject_Release( obj );
     }
 
+    IEnumWbemClassObject_Release( result );
+    SysFreeString( query );
+
+    query = SysAllocString( L"SELECT AdapterRAM FROM Win32_VideoController" );
+    hr = IWbemServices_ExecQuery( services, wql, query, 0, NULL, &result );
+    if (hr != S_OK)
+    {
+        win_skip( "Win32_VideoController not available\n" );
+        return;
+    }
+
+    for (;;)
+    {
+        hr = IEnumWbemClassObject_Next( result, 10000, 1, &obj, &count );
+        if (hr != S_OK) break;
+        check_property( obj, L"__CLASS", VT_BSTR, CIM_STRING );
+        check_property( obj, L"__GENUS", VT_I4, CIM_SINT32 );
+        check_property( obj, L"__NAMESPACE", VT_NULL, CIM_STRING );
+        check_property( obj, L"__PATH", VT_NULL, CIM_STRING );
+        check_property( obj, L"__PROPERTY_COUNT", VT_I4, CIM_SINT32 );
+        check_property( obj, L"__RELPATH", VT_NULL, CIM_STRING );
+        check_property( obj, L"__SERVER", VT_NULL, CIM_STRING );
+        IWbemClassObject_Release( obj );
+    }
+
     IEnumWbemClassObject_Release( result );
     SysFreeString( query );
     SysFreeString( wql );




More information about the wine-cvs mailing list