Module: wine Branch: stable Commit: ec77942663bcd19c76ada852d11a48fa80d84425 URL: https://source.winehq.org/git/wine.git/?a=commit;h=ec77942663bcd19c76ada852d...
Author: Gijs Vermeulen gijsvrm@gmail.com Date: Tue Aug 11 12:01:46 2020 +0200
wbemprox: Set obj to NULL on error in get_object().
Signed-off-by: Gijs Vermeulen gijsvrm@gmail.com Signed-off-by: Hans Leidekker hans@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org (cherry picked from commit 11f2057768ed2d5416fad30d6e3e18683ffc17cd) Signed-off-by: Michael Stefaniuc mstefani@winehq.org
---
dlls/wbemprox/services.c | 6 +++++- dlls/wbemprox/tests/query.c | 8 ++++++-- 2 files changed, 11 insertions(+), 3 deletions(-)
diff --git a/dlls/wbemprox/services.c b/dlls/wbemprox/services.c index 8b3a3b1af42..6aa283da387 100644 --- a/dlls/wbemprox/services.c +++ b/dlls/wbemprox/services.c @@ -469,7 +469,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 a3a3565759f..be05165542c 100644 --- a/dlls/wbemprox/tests/query.c +++ b/dlls/wbemprox/tests/query.c @@ -342,19 +342,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 ); }