diff --git a/dlls/wbemprox/services.c b/dlls/wbemprox/services.c index c0e535b3a11..3a0963e1f6c 100644 --- a/dlls/wbemprox/services.c +++ b/dlls/wbemprox/services.c @@ -463,7 +463,11 @@ HRESULT get_object( const WCHAR *object_path, IWbemClassObject **obj ) return hr; } 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 ); free_path( path ); return hr; diff --git a/dlls/wbemprox/tests/query.c b/dlls/wbemprox/tests/query.c index d6c918c08de..df0c26aa979 100644 --- a/dlls/wbemprox/tests/query.c +++ b/dlls/wbemprox/tests/query.c @@ -338,19 +338,23 @@ static void test_Win32_Service( IWbemServices *services ) service = NULL; hr = IWbemServices_GetObject( services, NULL, 0, NULL, &service, NULL ); 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; hr = IWbemServices_GetObject( services, empty, 0, NULL, &service, NULL ); 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( class ); class = SysAllocString( L"Win32_Service.Name=\"nonexistent\"" ); + service = (IWbemClassObject *)0xdeadbeef; hr = IWbemServices_GetObject( services, class, 0, NULL, &service, NULL ); ok( hr == WBEM_E_NOT_FOUND, "got %#08x\n", hr ); + ok( service == NULL, "expected NULL service, got %p\n", service ); SysFreeString( class ); }