Kaydet (Commit) 7ca8407b authored tarafından Norbert Thiebaud's avatar Norbert Thiebaud

coverity#707499 coverity#735400 coverity#738541

Change-Id: Idc00fe9ad5158043cf2eee652567581111c89177
Reviewed-on: https://gerrit.libreoffice.org/2277Reviewed-by: 's avatarNorbert Thiebaud <nthiebaud@gmail.com>
Tested-by: 's avatarNorbert Thiebaud <nthiebaud@gmail.com>
üst 558e9564
...@@ -401,9 +401,6 @@ inline bool checkUnoStructCopy( bool bVBA, SbxVariableRef& refVal, SbxVariableRe ...@@ -401,9 +401,6 @@ inline bool checkUnoStructCopy( bool bVBA, SbxVariableRef& refVal, SbxVariableRe
SbUnoStructRefObject* pUnoStructObj = PTR_CAST(SbUnoStructRefObject,(SbxObject*)xVarObj); SbUnoStructRefObject* pUnoStructObj = PTR_CAST(SbUnoStructRefObject,(SbxObject*)xVarObj);
if ( ( !pUnoVal && !pUnoStructVal ) )
return false;
OUString sClassName = pUnoVal ? pUnoVal->GetClassName() : pUnoStructVal->GetClassName(); OUString sClassName = pUnoVal ? pUnoVal->GetClassName() : pUnoStructVal->GetClassName();
OUString sName = pUnoVal ? pUnoVal->GetName() : pUnoStructVal->GetName(); OUString sName = pUnoVal ? pUnoVal->GetName() : pUnoStructVal->GetName();
...@@ -965,19 +962,18 @@ void SbiRuntime::StepREDIMP() ...@@ -965,19 +962,18 @@ void SbiRuntime::StepREDIMP()
short nDimsNew = pNewArray->GetDims(); short nDimsNew = pNewArray->GetDims();
short nDimsOld = pOldArray->GetDims(); short nDimsOld = pOldArray->GetDims();
short nDims = nDimsNew; short nDims = nDimsNew;
bool bRangeError = false;
// Store dims to use them for copying later
sal_Int32* pLowerBounds = new sal_Int32[nDims];
sal_Int32* pUpperBounds = new sal_Int32[nDims];
sal_Int32* pActualIndices = new sal_Int32[nDims];
if( nDimsOld != nDimsNew ) if( nDimsOld != nDimsNew )
{ {
bRangeError = true; StarBASIC::Error( SbERR_OUT_OF_RANGE );
} }
else else
{ {
// Store dims to use them for copying later
sal_Int32* pLowerBounds = new sal_Int32[nDims];
sal_Int32* pUpperBounds = new sal_Int32[nDims];
sal_Int32* pActualIndices = new sal_Int32[nDims];
// Compare bounds // Compare bounds
for( short i = 1 ; i <= nDims ; i++ ) for( short i = 1 ; i <= nDims ; i++ )
{ {
...@@ -991,24 +987,16 @@ void SbiRuntime::StepREDIMP() ...@@ -991,24 +987,16 @@ void SbiRuntime::StepREDIMP()
pActualIndices[j] = pLowerBounds[j] = lBoundNew; pActualIndices[j] = pLowerBounds[j] = lBoundNew;
pUpperBounds[j] = uBoundNew; pUpperBounds[j] = uBoundNew;
} }
}
if( bRangeError )
{
StarBASIC::Error( SbERR_OUT_OF_RANGE );
}
else
{
// Copy data from old array by going recursively through all dimensions // Copy data from old array by going recursively through all dimensions
// (It would be faster to work on the flat internal data array of an // (It would be faster to work on the flat internal data array of an
// SbyArray but this solution is clearer and easier) // SbyArray but this solution is clearer and easier)
implCopyDimArray( pNewArray, pOldArray, nDims - 1, implCopyDimArray( pNewArray, pOldArray, nDims - 1,
0, pActualIndices, pLowerBounds, pUpperBounds ); 0, pActualIndices, pLowerBounds, pUpperBounds );
delete[] pUpperBounds;
delete[] pLowerBounds;
delete[] pActualIndices;
} }
delete[] pUpperBounds;
delete[] pLowerBounds;
delete[] pActualIndices;
refRedimpArray = NULL; refRedimpArray = NULL;
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment