[Libreoffice-commits] .: 5 commits - sw/source

Marc-André Laverdière malaverdiere at kemper.freedesktop.org
Thu Jul 28 23:08:55 PDT 2011


 sw/source/core/layout/calcmove.cxx |    6 +++---
 sw/source/core/layout/wsfrm.cxx    |   13 +++++++------
 sw/source/filter/ww8/ww8par2.cxx   |   30 ++++++++++++++----------------
 sw/source/filter/ww8/ww8par6.cxx   |   29 +++++++++++++++--------------
 sw/source/filter/ww8/ww8scan.cxx   |    3 ++-
 5 files changed, 41 insertions(+), 40 deletions(-)

New commits:
commit 560b004d9812a76783c701724043f6cee70c0928
Author: Marc-Andre Laverdiere <marc-andre at atc.tcs.com>
Date:   Mon Jul 25 17:15:04 2011 +0530

    Fixed invalid array dereference

diff --git a/sw/source/filter/ww8/ww8par6.cxx b/sw/source/filter/ww8/ww8par6.cxx
index 357711a..9624079 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));
     }
commit b2f9a798a010f76e887a7f10c6f0af667fe48e81
Author: Marc-Andre Laverdiere <marc-andre at atc.tcs.com / marcandre.laverdiere at tcs.com>
Date:   Wed Jul 20 11:36:38 2011 +0530

    Fixes for segfault on an edge case + translations
    
    Fixed segfault due to reading an invalid pointer returned by GetStyle
    Translated some of the comments
    Added some proofing against similar bugs from GetStyle that may happen
    in other edge cases
    Fixed compile warning

diff --git a/sw/source/filter/ww8/ww8par2.cxx b/sw/source/filter/ww8/ww8par2.cxx
index 3fa6a24..a833caa 100644
--- a/sw/source/filter/ww8/ww8par2.cxx
+++ b/sw/source/filter/ww8/ww8par2.cxx
@@ -842,22 +842,20 @@ void SwWW8ImplReader::Read_ANLevelNo( sal_uInt16, const sal_uInt8* pData, short
 
 void SwWW8ImplReader::Read_ANLevelDesc( sal_uInt16, const sal_uInt8* pData, short nLen ) // Sprm 12
 {
+    SwWW8StyInf * pStyInf = GetStyle(nAktColl);
+    if( !pAktColl || nLen <= 0                       // only for Styledef
+        || (pStyInf && !pStyInf->bColl)              // ignore  CharFmt ->
+        || ( nIniFlags & WW8FL_NO_OUTLINE ) )
     {
-        SwWW8StyInf * pStyInf = GetStyle(nAktColl);
-        if( !pAktColl || nLen <= 0                  // nur bei Styledef
-            || (pStyInf && !pStyInf->bColl)              // CharFmt -> ignorieren
-            || ( nIniFlags & WW8FL_NO_OUTLINE ) ){
-            nSwNumLevel = 0xff;
-            return;
-        }
+        nSwNumLevel = 0xff;
+        return;
     }
 
-    if( nSwNumLevel <= MAXLEVEL         // Bereich WW:1..9 -> SW:0..8
-        && nSwNumLevel <= 9 ){      // keine Aufzaehlung / Nummerierung
 
-                                        // Falls bereits direkt oder durch
-                                        // Vererbung NumruleItems gesetzt sind,
-                                        // dann jetzt ausschalten
+    if( nSwNumLevel <= MAXLEVEL         // Value range mapping WW:1..9 -> SW:0..8
+        && nSwNumLevel <= 9 ){          // No Bullets or Numbering
+
+        // If NumRuleItems were set, either directly or through inheritance, disable them now
         pAktColl->SetFmtAttr( SwNumRuleItem() );
 
         String aName(CREATE_CONST_ASC( "Outline" ));
@@ -868,15 +866,14 @@ void SwWW8ImplReader::Read_ANLevelDesc( sal_uInt16, const sal_uInt8* pData, shor
 
         SetAnld(&aNR, (WW8_ANLD*)pData, nSwNumLevel, true);
 
-            // fehlende Level muessen nicht aufgefuellt werden
-
+        // Missing Levels need not be replenished
         rDoc.SetOutlineNumRule( aNR );
     }else if( pStyles->nWwNumLevel == 10 || pStyles->nWwNumLevel == 11 ){
         SwNumRule* pNR = GetStyRule();
         SetAnld(pNR, (WW8_ANLD*)pData, 0, false);
         pAktColl->SetFmtAttr( SwNumRuleItem( pNR->GetName() ) );
 
-        SwWW8StyInf * pStyInf = GetStyle(nAktColl);
+        pStyInf = GetStyle(nAktColl);
         if (pStyInf != NULL)
             pStyInf->bHasStyNumRule = true;
     }
@@ -994,7 +991,7 @@ void SwWW8ImplReader::StartAnl(const sal_uInt8* pSprm13)
     }
 
     SwWW8StyInf * pStyInf = GetStyle(nAktColl);
-    if (!sNumRule.Len() && pStyInf->bHasStyNumRule)
+    if (!sNumRule.Len() && pStyInf != NULL &&  pStyInf->bHasStyNumRule)
     {
         sNumRule = pStyInf->pFmt->GetNumRule().GetValue();
         pNumRule = rDoc.FindNumRulePtr(sNumRule);
@@ -3831,6 +3828,7 @@ bool WW8RStyle::PrepareStyle(SwWW8StyInf &rSI, ww::sti eSti, sal_uInt16 nThisSty
 {
     SwFmt* pColl;
     bool bStyExist;
+
     if (rSI.bColl)
     {
         // Para-Style
commit 5d7caec204e704c62d670cc90a39e8cfc78479c6
Author: Marc-Andre Laverdiere <marc-andre at atc.tcs.com>
Date:   Mon Jul 25 17:23:06 2011 +0530

    Fixed valgrind error
    
    Complained about switching on an unitialized value

diff --git a/sw/source/core/layout/wsfrm.cxx b/sw/source/core/layout/wsfrm.cxx
index 9aafc0d..e49871d 100644
--- a/sw/source/core/layout/wsfrm.cxx
+++ b/sw/source/core/layout/wsfrm.cxx
@@ -95,12 +95,13 @@ SwFrm::SwFrm( SwModify *pMod, SwFrm* pSib ) :
     pUpper( 0 ),
     pNext( 0 ),
     pPrev( 0 ),
-    pDrawObjs( 0 )
-    , bInfBody( sal_False )
-    , bInfTab ( sal_False )
-    , bInfFly ( sal_False )
-    , bInfFtn ( sal_False )
-    , bInfSct ( sal_False )
+    pDrawObjs( 0 ),
+    nType(0),
+    bInfBody( sal_False ),
+    bInfTab ( sal_False ),
+    bInfFly ( sal_False ),
+    bInfFtn ( sal_False ),
+    bInfSct ( sal_False )
 {
 #if OSL_DEBUG_LEVEL > 1
     bFlag01 = bFlag02 = bFlag03 = bFlag04 = bFlag05 = 0;
commit a1c11fa56aef80b4a9a47054029613fb06a30832
Author: Marc-Andre Laverdiere <marc-andre at atc.tcs.com>
Date:   Mon Jul 25 18:07:47 2011 +0530

    Fixed invalid array bounds read in ww8scan.cxx

diff --git a/sw/source/filter/ww8/ww8scan.cxx b/sw/source/filter/ww8/ww8scan.cxx
index 3782dfd..9e18737 100644
--- a/sw/source/filter/ww8/ww8scan.cxx
+++ b/sw/source/filter/ww8/ww8scan.cxx
@@ -6443,7 +6443,8 @@ WW8Fonts::WW8Fonts( SvStream& rSt, WW8Fib& rFib )
                 if ((eEnc == RTL_TEXTENCODING_SYMBOL) || (eEnc == RTL_TEXTENCODING_DONTKNOW))
                     eEnc = RTL_TEXTENCODING_MS_1252;
                 p->sFontname = String(pVer6->szFfn, eEnc);
-                if (p->ibszAlt)
+                const sal_uInt16 maxStrSize = SAL_N_ELEMENTS(pVer6->szFfn);
+                if (p->ibszAlt && p->ibszAlt < maxStrSize) //don't start after end of string
                 {
                     p->sFontname.Append(';');
                     p->sFontname += String(pVer6->szFfn+p->ibszAlt, eEnc);
commit 6f32f7f8896dcb21e983adcb61ed400db7389a34
Author: Marc-Andre Laverdiere <marc-andre at atc.tcs.com>
Date:   Mon Jul 25 14:07:58 2011 +0530

    Fixed invalid pointer dereference

diff --git a/sw/source/core/layout/calcmove.cxx b/sw/source/core/layout/calcmove.cxx
index 04df070..0b0b94a 100644
--- a/sw/source/core/layout/calcmove.cxx
+++ b/sw/source/core/layout/calcmove.cxx
@@ -313,9 +313,9 @@ void SwFrm::PrepareMake()
         else if ( bCnt && sal_True == (bFoll = pThis->IsFollow()) &&
              GetPrev() )
         {
-            //Wenn der Master gereade ein CalcFollow ruft braucht die Kette
-            //nicht durchlaufen werden. Das spart Zeit und vermeidet Probleme.
-            if ( ((SwTxtFrm*)((SwTxtFrm*)this)->FindMaster())->IsLocked() )
+            //Do not follow the chain when we need only one instance
+            const SwTxtFrm* pMaster = ((SwCntntFrm*)this)->FindMaster();
+            if ( pMaster && pMaster->IsLocked() )
             {
                 MakeAll();
                 return;


More information about the Libreoffice-commits mailing list