safearray patch

Ove Kaaven ovek at arcticnet.no
Sat Oct 13 12:20:40 CDT 2001


Log:
Ove Kaaven <ovek at transgaming.com>
Fixed bugs in safe arrays.
- enlarging a safe array didn't clear the new entries
- element access only validated the first dimension
- the validation always failed when the array contained 1 element

Index: dlls/oleaut32/safearray.c
===================================================================
RCS file: /home/wine/wine/dlls/oleaut32/safearray.c,v
retrieving revision 1.11
diff -u -r1.11 safearray.c
--- dlls/oleaut32/safearray.c	2001/09/21 21:01:31	1.11
+++ dlls/oleaut32/safearray.c	2001/10/13 15:46:03
@@ -785,6 +785,8 @@
     /* delta in number of spot implied by modifying the last dimension */
     lDelta *= psa->rgsabound[cDims].cElements;
 
+  TRACE("elements=%ld, Lbound=%ld (delta=%ld)\n", psaboundNew->cElements, psaboundNew->lLbound, lDelta);
+
   if (lDelta == 0) { ;/* same size, maybe a change of lLbound, just set it */
 
   } else /* need to enlarge (lDelta +) reduce (lDelta -) */
@@ -882,7 +884,7 @@
        optional but we do it anyway becuase the benefit is that we are 
        releasing to the system the unused memory */
 
-    if((pvNewBlock = HeapReAlloc(GetProcessHeap(), 0, psa->pvData, 
+    if((pvNewBlock = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, psa->pvData, 
        (ulWholeArraySize + lDelta) * psa->cbElements)) == NULL) 
         return FALSE; /* TODO If we get here it means:
                          SHRINK situation :  we've deleted the undesired
@@ -895,7 +897,7 @@
     /* Allocate a new block, because the previous data has been allocated with 
        the descriptor in SafeArrayCreateVector function. */
 
-    if((pvNewBlock = HeapAlloc(GetProcessHeap(), 0,
+    if((pvNewBlock = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
        ulWholeArraySize * psa->cbElements)) == NULL) 
         return FALSE;
 
@@ -992,21 +994,21 @@
   LONG    lLBound;
   HRESULT hRes;
 
+  if (!psa->cDims) return FALSE;
   for(; iter<psa->cDims; iter++) {
+    TRACE("coor[%d]=%ld\n", iter, coor[iter]);
     if((hRes = SafeArrayGetLBound(psa, (iter+1), &lLBound)) != S_OK)
       return FALSE;
     if((hRes = SafeArrayGetUBound(psa, (iter+1), &lUBound)) != S_OK)
       return FALSE;
  
-    if(lLBound == lUBound) 
+    if(lLBound > lUBound) 
       return FALSE; 
-   
-    if((coor[iter] >= lLBound) && (coor[iter] <= lUBound))
-      return TRUE;
-    else
+
+    if((coor[iter] < lLBound) || (coor[iter] > lUBound))
       return FALSE;
   }
-  return FALSE;
+  return TRUE;
 }  
 
 /************************************************************************ 





More information about the wine-patches mailing list