Commit 4b9d3909 authored by Rémi Bernon's avatar Rémi Bernon Committed by Alexandre Julliard

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: 's avatarRémi Bernon <rbernon@codeweavers.com> Signed-off-by: 's avatarHans Leidekker <hans@codeweavers.com> Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent 0167e195
......@@ -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;
......
......@@ -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 );
......@@ -1434,6 +1441,31 @@ static void test_Win32_VideoController( IWbemServices *services )
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 );
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment