[PATCH] wbemprox: Return WBEM_E_NOT_FOUND from get_object() if no object is available.

Zebediah Figura z.figura12 at gmail.com
Sun Aug 9 19:30:09 CDT 2020


Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=49685
Signed-off-by: Zebediah Figura <z.figura12 at gmail.com>
---
 dlls/wbemprox/services.c    |  4 +++-
 dlls/wbemprox/tests/query.c | 10 ++++++++--
 2 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/dlls/wbemprox/services.c b/dlls/wbemprox/services.c
index e2b452e217e..c0e535b3a11 100644
--- a/dlls/wbemprox/services.c
+++ b/dlls/wbemprox/services.c
@@ -450,6 +450,7 @@ HRESULT get_object( const WCHAR *object_path, IWbemClassObject **obj )
 {
     IEnumWbemClassObject *iter;
     struct path *path;
+    ULONG count;
     HRESULT hr;
 
     hr = parse_path( object_path, &path );
@@ -461,7 +462,8 @@ HRESULT get_object( const WCHAR *object_path, IWbemClassObject **obj )
         free_path( path );
         return hr;
     }
-    hr = create_class_object( path->class, iter, 0, NULL, obj );
+    hr = IEnumWbemClassObject_Next( iter, WBEM_INFINITE, 1, obj, &count );
+    if (hr == WBEM_S_FALSE) hr = WBEM_E_NOT_FOUND;
     IEnumWbemClassObject_Release( iter );
     free_path( path );
     return hr;
diff --git a/dlls/wbemprox/tests/query.c b/dlls/wbemprox/tests/query.c
index e48722f3bc9..a50002e1baf 100644
--- a/dlls/wbemprox/tests/query.c
+++ b/dlls/wbemprox/tests/query.c
@@ -267,7 +267,9 @@ static void test_Win32_Service( IWbemServices *services )
     if (hr != S_OK)
     {
         win_skip( "Win32_Service not available\n" );
-        goto out;
+        SysFreeString( empty );
+        SysFreeString( class );
+        return;
     }
 
     check_property( service, L"ProcessID", VT_I4, CIM_UINT32 );
@@ -343,9 +345,13 @@ static void test_Win32_Service( IWbemServices *services )
     ok( hr == S_OK, "got %08x\n", hr );
     if (service) IWbemClassObject_Release( service );
 
-out:
     SysFreeString( empty );
     SysFreeString( class );
+
+    class = SysAllocString( L"Win32_Service.Name=\"nonexistent\"" );
+    hr = IWbemServices_GetObject( services, class, 0, NULL, &service, NULL );
+    ok( hr == WBEM_E_NOT_FOUND, "got %#08x\n", hr );
+    SysFreeString( class );
 }
 
 static void test_Win32_Bios( IWbemServices *services )
-- 
2.28.0




More information about the wine-devel mailing list