wbemprox: Return an empty object if the path is NULL or empty.

Hans Leidekker hans at codeweavers.com
Mon Jan 28 08:56:40 CST 2013


---
 dlls/wbemprox/class.c       |    4 ++--
 dlls/wbemprox/services.c    |    8 +++-----
 dlls/wbemprox/tests/query.c |   15 ++++++++++++++-
 3 files changed, 19 insertions(+), 8 deletions(-)

diff --git a/dlls/wbemprox/class.c b/dlls/wbemprox/class.c
index f47987d..5205515 100644
--- a/dlls/wbemprox/class.c
+++ b/dlls/wbemprox/class.c
@@ -1015,8 +1015,8 @@ HRESULT create_class_object( const WCHAR *name, IEnumWbemClassObject *iter, UINT
 
     co->IWbemClassObject_iface.lpVtbl = &class_object_vtbl;
     co->refs  = 1;
-    co->name  = heap_strdupW( name );
-    if (!co->name)
+    if (!name) co->name = NULL;
+    else if (!(co->name = heap_strdupW( name )))
     {
         heap_free( co );
         return E_OUTOFMEMORY;
diff --git a/dlls/wbemprox/services.c b/dlls/wbemprox/services.c
index 4bcd824..bf202be 100644
--- a/dlls/wbemprox/services.c
+++ b/dlls/wbemprox/services.c
@@ -352,11 +352,9 @@ static HRESULT WINAPI wbem_services_GetObject(
 
     if (lFlags) FIXME("unsupported flags 0x%08x\n", lFlags);
 
-    if (!strObjectPath)
-    {
-        FIXME("no support for creating new classes\n");
-        return WBEM_E_FAILED;
-    }
+    if (!strObjectPath || !strObjectPath[0])
+        return create_class_object( NULL, NULL, 0, NULL, ppObject );
+
     return get_object( strObjectPath, ppObject );
 }
 
diff --git a/dlls/wbemprox/tests/query.c b/dlls/wbemprox/tests/query.c
index 014bac4..dd3424f 100644
--- a/dlls/wbemprox/tests/query.c
+++ b/dlls/wbemprox/tests/query.c
@@ -146,7 +146,8 @@ static void test_Win32_Service( IWbemServices *services )
     static const WCHAR stoppedW[] = {'S','t','o','p','p','e','d',0};
     static const WCHAR serviceW[] = {'W','i','n','3','2','_','S','e','r','v','i','c','e','.',
         'N','a','m','e','=','"','S','p','o','o','l','e','r','"',0};
-    BSTR class = SysAllocString( serviceW ), method;
+    static const WCHAR emptyW[] = {0};
+    BSTR class = SysAllocString( serviceW ), empty = SysAllocString( emptyW ), method;
     IWbemClassObject *service, *out;
     VARIANT state, retval;
     CIMTYPE type;
@@ -219,6 +220,18 @@ static void test_Win32_Service( IWbemServices *services )
     }
     VariantClear( &state );
     IWbemClassObject_Release( service );
+
+    service = NULL;
+    hr = IWbemServices_GetObject( services, NULL, 0, NULL, &service, NULL );
+    ok( hr == S_OK, "got %08x\n", hr );
+    if (service) 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 );
+
+    SysFreeString( empty );
     SysFreeString( class );
 }
 
-- 
1.7.10.4






More information about the wine-patches mailing list