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
This commit is contained in:
parent
d418682da7
commit
d63cf5f846
@ -785,6 +785,8 @@ HRESULT WINAPI SafeArrayRedim(
|
|||||||
/* delta in number of spot implied by modifying the last dimension */
|
/* delta in number of spot implied by modifying the last dimension */
|
||||||
lDelta *= psa->rgsabound[cDims].cElements;
|
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 */
|
if (lDelta == 0) { ;/* same size, maybe a change of lLbound, just set it */
|
||||||
|
|
||||||
} else /* need to enlarge (lDelta +) reduce (lDelta -) */
|
} else /* need to enlarge (lDelta +) reduce (lDelta -) */
|
||||||
@ -882,7 +884,7 @@ static BOOL resizeSafeArray(
|
|||||||
optional but we do it anyway becuase the benefit is that we are
|
optional but we do it anyway becuase the benefit is that we are
|
||||||
releasing to the system the unused memory */
|
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)
|
(ulWholeArraySize + lDelta) * psa->cbElements)) == NULL)
|
||||||
return FALSE; /* TODO If we get here it means:
|
return FALSE; /* TODO If we get here it means:
|
||||||
SHRINK situation : we've deleted the undesired
|
SHRINK situation : we've deleted the undesired
|
||||||
@ -895,7 +897,7 @@ static BOOL resizeSafeArray(
|
|||||||
/* Allocate a new block, because the previous data has been allocated with
|
/* Allocate a new block, because the previous data has been allocated with
|
||||||
the descriptor in SafeArrayCreateVector function. */
|
the descriptor in SafeArrayCreateVector function. */
|
||||||
|
|
||||||
if((pvNewBlock = HeapAlloc(GetProcessHeap(), 0,
|
if((pvNewBlock = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
|
||||||
ulWholeArraySize * psa->cbElements)) == NULL)
|
ulWholeArraySize * psa->cbElements)) == NULL)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
@ -992,21 +994,21 @@ static BOOL validCoordinate(
|
|||||||
LONG lLBound;
|
LONG lLBound;
|
||||||
HRESULT hRes;
|
HRESULT hRes;
|
||||||
|
|
||||||
|
if (!psa->cDims) return FALSE;
|
||||||
for(; iter<psa->cDims; iter++) {
|
for(; iter<psa->cDims; iter++) {
|
||||||
|
TRACE("coor[%d]=%ld\n", iter, coor[iter]);
|
||||||
if((hRes = SafeArrayGetLBound(psa, (iter+1), &lLBound)) != S_OK)
|
if((hRes = SafeArrayGetLBound(psa, (iter+1), &lLBound)) != S_OK)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
if((hRes = SafeArrayGetUBound(psa, (iter+1), &lUBound)) != S_OK)
|
if((hRes = SafeArrayGetUBound(psa, (iter+1), &lUBound)) != S_OK)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
if(lLBound == lUBound)
|
if(lLBound > lUBound)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
if((coor[iter] >= lLBound) && (coor[iter] <= lUBound))
|
if((coor[iter] < lLBound) || (coor[iter] > lUBound))
|
||||||
return TRUE;
|
|
||||||
else
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
return FALSE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
|
Loading…
x
Reference in New Issue
Block a user