[PATCH 2/2] wbemprox: Don't crash in IWbemClassObject::Put() when called with empty class object.

Gijs Vermeulen gijsvrm at gmail.com
Tue Aug 11 05:01:47 CDT 2020


Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=40945
Signed-off-by: Gijs Vermeulen <gijsvrm at gmail.com>
---
 dlls/wbemprox/class.c       | 3 +++
 dlls/wbemprox/tests/query.c | 9 ++++++++-
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/dlls/wbemprox/class.c b/dlls/wbemprox/class.c
index 1a00cfc40a..e048fb3db8 100644
--- a/dlls/wbemprox/class.c
+++ b/dlls/wbemprox/class.c
@@ -460,6 +460,9 @@ static HRESULT WINAPI class_object_Put(
         if ((hr = get_column_index( co->record->table, wszName, &index )) != S_OK) return hr;
         return record_set_value( co->record, index, pVal );
     }
+
+    if (!ec) return S_OK;
+
     return put_propval( ec->query->view, co->index, wszName, pVal, Type );
 }
 
diff --git a/dlls/wbemprox/tests/query.c b/dlls/wbemprox/tests/query.c
index df0c26aa97..17942cd89a 100644
--- a/dlls/wbemprox/tests/query.c
+++ b/dlls/wbemprox/tests/query.c
@@ -259,7 +259,7 @@ static void test_Win32_Service( IWbemServices *services )
 {
     BSTR class = SysAllocString( L"Win32_Service.Name=\"Spooler\"" ), empty = SysAllocString( L"" ), method;
     IWbemClassObject *service, *out;
-    VARIANT state, retval;
+    VARIANT state, retval, classvar;
     CIMTYPE type;
     HRESULT hr;
 
@@ -339,6 +339,13 @@ static void test_Win32_Service( IWbemServices *services )
     hr = IWbemServices_GetObject( services, NULL, 0, NULL, &service, NULL );
     ok( hr == S_OK, "got %08x\n", hr );
     ok( !!service, "expected non-NULL service\n" );
+
+    VariantInit(&classvar);
+    V_VT(&classvar) = VT_BSTR;
+    V_BSTR(&classvar) = SysAllocString(L"MyClass");
+    hr = IWbemClassObject_Put(service, L"__CLASS", 0, &classvar, 0);
+    ok( hr == S_OK, "got %08x\n", hr );
+    VariantClear(&classvar);
     IWbemClassObject_Release( service );
 
     service = NULL;
-- 
2.28.0




More information about the wine-devel mailing list