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@codeweavers.com>
Signed-off-by: Hans Leidekker <hans@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Rémi Bernon 2020-09-30 12:37:39 +02:00 committed by Alexandre Julliard
parent 0167e195e9
commit 4b9d3909b8
2 changed files with 40 additions and 4 deletions

View File

@ -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;

View File

@ -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 );