diff options
author | Marc-Andre Laverdiere <marc-andre@atc.tcs.com> | 2011-07-25 17:15:04 +0530 |
---|---|---|
committer | Marc-Andre Laverdiere <marc-andre@atc.tcs.com> | 2011-07-29 11:15:19 +0530 |
commit | cf60f162e61e020ea19fbf7536b69fd7eb9426cb (patch) | |
tree | 155c76a01f0296c37361cb2e25adf2a17c52d897 | |
parent | d7a666a8f3f8e04d121578052f91b9e0c01b4632 (diff) |
Fixed invalid array dereference
-rw-r--r-- | sw/source/filter/ww8/ww8par6.cxx | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/sw/source/filter/ww8/ww8par6.cxx b/sw/source/filter/ww8/ww8par6.cxx index e667857ba2fc..fe51ef48dcd6 100644 --- a/sw/source/filter/ww8/ww8par6.cxx +++ b/sw/source/filter/ww8/ww8par6.cxx @@ -332,19 +332,21 @@ void SwWW8ImplReader::Read_ParaBiDi(sal_uInt16, const sal_uInt8* pData, short nL bool wwSectionManager::SetCols(SwFrmFmt &rFmt, const wwSection &rSection, sal_uInt32 nNettoWidth) const { - //sprmSCcolumns - Anzahl der Spalten - 1 - sal_Int16 nCols = rSection.NoCols(); + //sprmSCcolumns - number of columns - 1 + const sal_Int16 nCols = rSection.NoCols(); - if (nCols < 2) - return false; // keine oder bloedsinnige Spalten + if (nCols < 2) //check for no columns or other wierd state + return false; - SwFmtCol aCol; // Erzeuge SwFmtCol + SwFmtCol aCol; // Create SwFmtCol - //sprmSDxaColumns - Default-Abstand 1.25 cm + //sprmSDxaColumns - Default distance is 1.25 cm sal_Int32 nColSpace = rSection.StandardColSeperation(); + const SEPr& rSep = rSection.maSep; + // sprmSLBetween - if (rSection.maSep.fLBetween) + if (rSep.fLBetween) { aCol.SetLineAdj(COLADJ_TOP); // Line aCol.SetLineHeight(100); @@ -356,21 +358,20 @@ bool wwSectionManager::SetCols(SwFrmFmt &rFmt, const wwSection &rSection, writer_cast<sal_uInt16>(nNettoWidth)); // sprmSFEvenlySpaced - if (!rSection.maSep.fEvenlySpaced) + if (!rSep.fEvenlySpaced) { aCol._SetOrtho(false); - int nIdx = 1; - for (sal_uInt16 i = 0; i < nCols; i++ ) + const sal_uInt16 maxIdx = SAL_N_ELEMENTS(rSep.rgdxaColumnWidthSpacing); + for (sal_uInt16 i = 0, nIdx = 1; i < nCols && nIdx < maxIdx; i++, nIdx+=2 ) { SwColumn* pCol = aCol.GetColumns()[i]; - sal_Int32 nLeft = rSection.maSep.rgdxaColumnWidthSpacing[nIdx-1]/2; - sal_Int32 nRight = rSection.maSep.rgdxaColumnWidthSpacing[nIdx+1]/2; - sal_Int32 nWishWidth = rSection.maSep.rgdxaColumnWidthSpacing[nIdx] + const sal_Int32 nLeft = rSep.rgdxaColumnWidthSpacing[nIdx-1]/2; + const sal_Int32 nRight = rSep.rgdxaColumnWidthSpacing[nIdx+1]/2; + const sal_Int32 nWishWidth = rSep.rgdxaColumnWidthSpacing[nIdx] + nLeft + nRight; pCol->SetWishWidth(writer_cast<sal_uInt16>(nWishWidth)); pCol->SetLeft(writer_cast<sal_uInt16>(nLeft)); pCol->SetRight(writer_cast<sal_uInt16>(nRight)); - nIdx += 2; } aCol.SetWishWidth(writer_cast<sal_uInt16>(nNettoWidth)); } |