PATCH: installshield fix for GW Messenger Client

Marcus Meissner marcus at jet.franken.de
Sun Sep 19 12:18:32 CDT 2004


Hi,

Again a fix necessary to run our regression testsuite "InstallShield".

SafeArrayGetElement(..., &variant) on an array of VARIANTs does not honor any 
previous content of "variant".

Novell Groupwise Messenger Client now installs.

Ciao, Marcus
	Marcus Meissner <meissner at novell.com>
	SafeArrayGetElement on a VARIANT array does not free the
	previous VARIANT in the passed pointer. Added testcase.

Index: dlls/oleaut32/safearray.c
===================================================================
RCS file: /home/wine/wine/dlls/oleaut32/safearray.c,v
retrieving revision 1.39
diff -u -r1.39 safearray.c
--- dlls/oleaut32/safearray.c	22 Aug 2004 21:38:46 -0000	1.39
+++ dlls/oleaut32/safearray.c	19 Sep 2004 17:12:48 -0000
@@ -342,7 +342,9 @@
 
       while(ulCellCount--)
       {
-        VariantClear(lpVariant);
+        HRESULT hRet = VariantClear(lpVariant);
+
+        if (FAILED(hRet)) FIXME("VariantClear of element failed!\n");
         lpVariant++;
       }
     }
@@ -369,7 +371,10 @@
 
       while(ulCellCount--)
       {
-        VariantCopy(lpDest, lpVariant);
+        HRESULT hRet;
+
+        hRet = VariantCopy(lpDest, lpVariant);
+        if (FAILED(hRet)) FIXME("VariantCopy failed with 0x%lx\n", hRet);
         lpVariant++;
         lpDest++;
       }
@@ -874,8 +879,10 @@
         VARIANT* lpVariant = (VARIANT*)pvData;
         VARIANT* lpDest = (VARIANT*)lpvDest;
 
-        VariantClear(lpDest);
-        VariantCopy(lpDest, lpVariant);
+        hRet = VariantClear(lpDest);
+        if (FAILED(hRet)) FIXME("VariantClear failed with 0x%lx\n", hRet);
+        hRet = VariantCopy(lpDest, lpVariant);
+        if (FAILED(hRet)) FIXME("VariantCopy failed with 0x%lx\n", hRet);
       }
       else if (psa->fFeatures & FADF_BSTR)
       {
@@ -959,7 +966,10 @@
         VARIANT* lpVariant = (VARIANT*)lpvSrc;
         VARIANT* lpDest = (VARIANT*)pvData;
 
-        VariantCopy(lpDest, lpVariant);
+        /* The original content of pvData is ignored. */
+        V_VT(lpDest) = VT_EMPTY;
+        hRet = VariantCopy(lpDest, lpVariant);
+	if (FAILED(hRet)) FIXME("VariantCopy failed with 0x%lx\n", hRet);
       }
       else if (psa->fFeatures & FADF_BSTR)
       {
Index: dlls/oleaut32/tests/safearray.c
===================================================================
RCS file: /home/wine/wine/dlls/oleaut32/tests/safearray.c,v
retrieving revision 1.16
diff -u -r1.16 safearray.c
--- dlls/oleaut32/tests/safearray.c	1 Sep 2004 04:53:52 -0000	1.16
+++ dlls/oleaut32/tests/safearray.c	19 Sep 2004 17:12:49 -0000
@@ -1087,6 +1087,47 @@
   ok(tunk_xref == 2,"Failed to decrement refcount of iface.\n");
 }
 
+static void test_SafeArrayGetPutElement_VARIANT(void)
+{
+  SAFEARRAYBOUND sab;
+  LONG indices[1];
+  SAFEARRAY *sa;
+  HRESULT hres;
+  VARIANT value, gotvalue;
+
+  sab.lLbound = 1;
+  sab.cElements = 1;
+  sa = SafeArrayCreate(VT_VARIANT, 1, &sab);
+  ok(sa != NULL, "VARIANT test couldn't create array\n");
+  if (!sa)
+    return;
+
+  ok(sa->cbElements == sizeof(VARIANT), "VARIANT size mismatch\n");
+  if (sa->cbElements != sizeof(VARIANT))
+    return;
+
+  indices[0] = sab.lLbound;
+  V_VT(&value) = VT_I4;
+  V_I4(&value) = 0x42424242;
+  hres = SafeArrayPutElement(sa, indices, &value);
+  ok(hres == S_OK, "Failed to put Variant I4 element hres 0x%lx\n", hres);
+
+  V_VT(&gotvalue) = 0xdead;
+  hres = SafeArrayGetElement(sa, indices, &gotvalue);
+  ok(hres == S_OK, "Failed to get variant element at hres 0x%lx\n", hres);
+
+  V_VT(&gotvalue) = VT_EMPTY;
+  hres = SafeArrayGetElement(sa, indices, &gotvalue);
+  ok(hres == S_OK, "Failed to get variant element at hres 0x%lx\n", hres);
+  if (hres == S_OK) {
+    ok(V_VT(&value) == V_VT(&gotvalue), "Got type 0x%x instead of 0x%x\n", V_VT(&value), V_VT(&gotvalue));
+    if (V_VT(&value) == V_VT(&gotvalue))
+    	ok(V_I4(&value) == V_I4(&gotvalue), "Got %d instead of %d\n", V_I4(&value), V_VT(&gotvalue));
+  }
+  SafeArrayDestroy(sa);
+}
+
+
 static void test_SafeArrayCopyData(void)
 {
   SAFEARRAYBOUND sab[4];
@@ -1520,4 +1561,5 @@
     test_SafeArrayGetPutElement();
     test_SafeArrayGetPutElement_BSTR();
     test_SafeArrayGetPutElement_IUnknown();
+    test_SafeArrayGetPutElement_VARIANT();
 }
-- 



More information about the wine-patches mailing list