Nikolay Sivov : oleaut32: Fix SafeArrayPutElement() for FADF_RECORD arrays.

Alexandre Julliard julliard at winehq.org
Mon Feb 24 15:42:30 CST 2014


Module: wine
Branch: master
Commit: a4e0fc95a914344781975b8971fbba511bbe1a5f
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=a4e0fc95a914344781975b8971fbba511bbe1a5f

Author: Nikolay Sivov <nsivov at codeweavers.com>
Date:   Mon Feb 24 08:15:21 2014 +0400

oleaut32: Fix SafeArrayPutElement() for FADF_RECORD arrays.

---

 dlls/oleaut32/safearray.c       |   34 +++++++++++++++++++---------------
 dlls/oleaut32/tests/safearray.c |   25 ++++++++++++++++++++++++-
 2 files changed, 43 insertions(+), 16 deletions(-)

diff --git a/dlls/oleaut32/safearray.c b/dlls/oleaut32/safearray.c
index b7d8b37..f66cc80 100644
--- a/dlls/oleaut32/safearray.c
+++ b/dlls/oleaut32/safearray.c
@@ -898,23 +898,27 @@ HRESULT WINAPI SafeArrayPutElement(SAFEARRAY *psa, LONG *rgIndices, void *pvData
         if (!*lpDest)
           hRet = E_OUTOFMEMORY;
       }
-      else
+      else if (psa->fFeatures & (FADF_UNKNOWN|FADF_DISPATCH))
       {
-        if (psa->fFeatures & (FADF_UNKNOWN|FADF_DISPATCH))
-        {
-          LPUNKNOWN  lpUnknown = pvData;
-          LPUNKNOWN *lpDest = lpvDest;
-
-          if (lpUnknown)
-            IUnknown_AddRef(lpUnknown);
-          if (*lpDest)
-            IUnknown_Release(*lpDest);
-	  *lpDest = lpUnknown;
-        } else {
-          /* Copy the data over */
-          memcpy(lpvDest, pvData, psa->cbElements);
-	}
+        IUnknown  *lpUnknown = pvData;
+        IUnknown **lpDest = lpvDest;
+
+        if (lpUnknown)
+          IUnknown_AddRef(lpUnknown);
+        if (*lpDest)
+          IUnknown_Release(*lpDest);
+        *lpDest = lpUnknown;
       }
+      else if (psa->fFeatures & FADF_RECORD)
+      {
+        IRecordInfo *record;
+
+        SafeArrayGetRecordInfo(psa, &record);
+        hRet = IRecordInfo_RecordCopy(record, pvData, lpvDest);
+        IRecordInfo_Release(record);
+      } else
+        /* Copy the data over */
+        memcpy(lpvDest, pvData, psa->cbElements);
     }
     SafeArrayUnlock(psa);
   }
diff --git a/dlls/oleaut32/tests/safearray.c b/dlls/oleaut32/tests/safearray.c
index 1af2cab..1d8943a 100644
--- a/dlls/oleaut32/tests/safearray.c
+++ b/dlls/oleaut32/tests/safearray.c
@@ -1062,10 +1062,11 @@ test_LockUnlock_Vector:
 static void test_SafeArrayGetPutElement(void)
 {
   SAFEARRAYBOUND sab[4];
-  LONG indices[NUM_DIMENSIONS];
+  LONG indices[NUM_DIMENSIONS], index;
   SAFEARRAY *sa;
   HRESULT hres;
   int value = 0, gotvalue, dimension;
+  IRecordInfoImpl *irec;
   unsigned int x,y,z,a;
 
   for (dimension = 0; dimension < NUM_DIMENSIONS; dimension++)
@@ -1184,6 +1185,28 @@ static void test_SafeArrayGetPutElement(void)
   }
   hres = SafeArrayDestroy(sa);
   ok(hres == S_OK, "got 0x%08x\n", hres);
+
+  /* VT_RECORD array */
+  irec = IRecordInfoImpl_Construct();
+  irec->ref = 1;
+
+  sab[0].lLbound = 0;
+  sab[0].cElements = 8;
+
+  sa = pSafeArrayCreateEx(VT_RECORD, 1, sab, &irec->IRecordInfo_iface);
+  ok(sa != NULL, "failed to create array\n");
+  ok(irec->ref == 2, "got %d\n", irec->ref);
+
+  index = 0;
+  irec->recordcopy = 0;
+  hres = SafeArrayPutElement(sa, &index, (void*)0xdeadbeef);
+  ok(hres == S_OK, "got 0x%08x\n", hres);
+  ok(irec->recordcopy == 1, "got %d\n", irec->recordcopy);
+
+  hres = SafeArrayDestroy(sa);
+  ok(hres == S_OK, "got 0x%08x\n", hres);
+  ok(irec->ref == 1, "got %d\n", irec->ref);
+  IRecordInfo_Release(&irec->IRecordInfo_iface);
 }
 
 static void test_SafeArrayGetPutElement_BSTR(void)




More information about the wine-cvs mailing list