diff options
author | Marc-Andre Laverdiere <marc-andre@atc.tcs.com> | 2011-07-25 17:15:04 +0530 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2011-08-09 11:15:24 +0100 |
commit | 2f151aae24ac54b5efd675f4b2f162e07e02ac10 (patch) | |
tree | 07f6efc7c0d6a028c47130ede0aced4e5b3f7f41 | |
parent | 81974ceb030b7209af1a55557e697c8acb339b7c (diff) |
Fixed invalid array dereference
(cherry picked from commit 560b004d9812a76783c701724043f6cee70c0928)
-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 65aa924e82..3df4de1c98 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)); } |