Commit 11f20577 authored by Gijs Vermeulen's avatar Gijs Vermeulen Committed by Alexandre Julliard

wbemprox: Set obj to NULL on error in get_object().

parent 9b7f14f1
...@@ -463,7 +463,11 @@ HRESULT get_object( const WCHAR *object_path, IWbemClassObject **obj ) ...@@ -463,7 +463,11 @@ HRESULT get_object( const WCHAR *object_path, IWbemClassObject **obj )
return hr; return hr;
} }
hr = IEnumWbemClassObject_Next( iter, WBEM_INFINITE, 1, obj, &count ); hr = IEnumWbemClassObject_Next( iter, WBEM_INFINITE, 1, obj, &count );
if (hr == WBEM_S_FALSE) hr = WBEM_E_NOT_FOUND; if (hr == WBEM_S_FALSE)
{
hr = WBEM_E_NOT_FOUND;
*obj = NULL;
}
IEnumWbemClassObject_Release( iter ); IEnumWbemClassObject_Release( iter );
free_path( path ); free_path( path );
return hr; return hr;
......
...@@ -338,19 +338,23 @@ static void test_Win32_Service( IWbemServices *services ) ...@@ -338,19 +338,23 @@ static void test_Win32_Service( IWbemServices *services )
service = NULL; service = NULL;
hr = IWbemServices_GetObject( services, NULL, 0, NULL, &service, NULL ); hr = IWbemServices_GetObject( services, NULL, 0, NULL, &service, NULL );
ok( hr == S_OK, "got %08x\n", hr ); ok( hr == S_OK, "got %08x\n", hr );
if (service) IWbemClassObject_Release( service ); ok( !!service, "expected non-NULL service\n" );
IWbemClassObject_Release( service );
service = NULL; service = NULL;
hr = IWbemServices_GetObject( services, empty, 0, NULL, &service, NULL ); hr = IWbemServices_GetObject( services, empty, 0, NULL, &service, NULL );
ok( hr == S_OK, "got %08x\n", hr ); ok( hr == S_OK, "got %08x\n", hr );
if (service) IWbemClassObject_Release( service ); ok( !!service, "expected non-NULL service\n" );
IWbemClassObject_Release( service );
SysFreeString( empty ); SysFreeString( empty );
SysFreeString( class ); SysFreeString( class );
class = SysAllocString( L"Win32_Service.Name=\"nonexistent\"" ); class = SysAllocString( L"Win32_Service.Name=\"nonexistent\"" );
service = (IWbemClassObject *)0xdeadbeef;
hr = IWbemServices_GetObject( services, class, 0, NULL, &service, NULL ); hr = IWbemServices_GetObject( services, class, 0, NULL, &service, NULL );
ok( hr == WBEM_E_NOT_FOUND, "got %#08x\n", hr ); ok( hr == WBEM_E_NOT_FOUND, "got %#08x\n", hr );
ok( service == NULL, "expected NULL service, got %p\n", service );
SysFreeString( class ); SysFreeString( class );
} }
......
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