[Libreoffice-commits] core.git: Branch 'libreoffice-5-1' - 6 commits - lotuswordpro/source

Caolán McNamara caolanm at redhat.com
Thu Dec 10 13:34:05 PST 2015


 lotuswordpro/source/filter/lwpfnlayout.cxx    |    2 +-
 lotuswordpro/source/filter/lwpframelayout.cxx |    9 ++++++---
 lotuswordpro/source/filter/lwpobjfactory.cxx  |    5 +++++
 lotuswordpro/source/filter/lwpobjfactory.hxx  |    3 ++-
 lotuswordpro/source/filter/lwppara.cxx        |    2 +-
 lotuswordpro/source/filter/lwppara1.cxx       |    2 +-
 lotuswordpro/source/filter/lwptblformula.cxx  |   17 ++++++++++++++++-
 7 files changed, 32 insertions(+), 8 deletions(-)

New commits:
commit 0c3d0311c16e9898b417b758f8b151c0ab10463e
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Thu Dec 10 21:28:39 2015 +0000

    need a dynamic cast here
    
    53rd and final distinct crash fix of this sequence
    
    Change-Id: Id170132c2082fd4905192adc840125088ef5da27
    (cherry picked from commit 3735b05668ffcaa37fcecf2907478616db52f2b4)

diff --git a/lotuswordpro/source/filter/lwpfnlayout.cxx b/lotuswordpro/source/filter/lwpfnlayout.cxx
index 7707eef..3ba3795 100644
--- a/lotuswordpro/source/filter/lwpfnlayout.cxx
+++ b/lotuswordpro/source/filter/lwpfnlayout.cxx
@@ -258,7 +258,7 @@ void LwpEnSuperTableLayout::XFConvert(XFContentContainer * /*pCont*/)
 
     while(!rID.IsNull())
     {
-        LwpVirtualLayout * pLayout = static_cast<LwpVirtualLayout *>(rID.obj().get());
+        LwpVirtualLayout * pLayout = dynamic_cast<LwpVirtualLayout*>(rID.obj().get());
         if(!pLayout)
         {
             break;
commit 1d88fa76834fc1fb04a285f77e8245a44c9091e8
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Thu Dec 10 21:24:32 2015 +0000

    guard against empty Story
    
    Change-Id: Ide44aed9a3189b0fd21a8adc039eb61bd3d3dc14
    (cherry picked from commit ef68438d384ed6dd919fa0f1a3830d2171f8e002)

diff --git a/lotuswordpro/source/filter/lwppara.cxx b/lotuswordpro/source/filter/lwppara.cxx
index 4b20405..327e016 100644
--- a/lotuswordpro/source/filter/lwppara.cxx
+++ b/lotuswordpro/source/filter/lwppara.cxx
@@ -669,7 +669,7 @@ void LwpPara::RegisterStyle()
                         if (!pPrePara)
                         {
                             LwpStory* pStory = pPara->GetStory();
-                            pPrePara = pStory->GetLastParaOfPreviousStory();
+                            pPrePara = pStory ? pStory->GetLastParaOfPreviousStory() : nullptr;
 
                             if (!pPrePara)
                             {
commit cf0d1237452ce327f046b33db9871fcf1e65c826
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Thu Dec 10 21:20:03 2015 +0000

    guard against broken formula and bad lengths
    
    Change-Id: Iab13d67fdc218c84400a4d84e177e5096bb68379
    (cherry picked from commit 1e0b9881b4dc7d002d5da767f1476fb1c2147fc7)

diff --git a/lotuswordpro/source/filter/lwptblformula.cxx b/lotuswordpro/source/filter/lwptblformula.cxx
index 0562eea..963377e 100644
--- a/lotuswordpro/source/filter/lwptblformula.cxx
+++ b/lotuswordpro/source/filter/lwptblformula.cxx
@@ -170,8 +170,13 @@ bool LwpFormulaInfo::ReadExpression()
     /* Read the compiled expression length */
     m_pObjStrm->SeekRel(2);
 
-    while ((TokenType = m_pObjStrm->QuickReaduInt16()) != TK_END)
+    bool bError = false;
+    while ((TokenType = m_pObjStrm->QuickReaduInt16(&bError)) != TK_END)
     {
+
+        if (bError)
+            throw std::runtime_error("error reading expression");
+
         // Get the disk length of this token
         DiskLength = m_pObjStrm->QuickReaduInt16();
 
@@ -221,19 +226,29 @@ bool LwpFormulaInfo::ReadExpression()
             case TK_NOT:
                 m_pObjStrm->SeekRel(DiskLength); // extensible for future
 
+                if (m_aStack.size() >= 2)
                 {//binary operator
                     LwpFormulaOp* pOp = new LwpFormulaOp(TokenType);
                     pOp->AddArg(m_aStack.back()); m_aStack.pop_back();
                     pOp->AddArg(m_aStack.back()); m_aStack.pop_back();
                     m_aStack.push_back(pOp);
                 }
+                else
+                {
+                    readSucceeded = false;
+                }
                 break;
             case TK_UNARY_MINUS:
+                if (!m_aStack.empty())
                 {
                     LwpFormulaUnaryOp* pOp = new LwpFormulaUnaryOp(TokenType);
                     pOp->AddArg(m_aStack.back()); m_aStack.pop_back();
                     m_aStack.push_back(pOp);
                 }
+                else
+                {
+                    readSucceeded = false;
+                }
                 break;
             default:
                 // We don't know what to do with this token, so eat it.
commit 32af2d9eb634aad4820b9406c89357099d01aaf8
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Thu Dec 10 21:06:01 2015 +0000

    check for null Modifiers
    
    Change-Id: I842122f7e2cba48d4798905f41f63b3e06775d00
    (cherry picked from commit 6834384e80cf5cd374cdec471ce385ba2ca94580)

diff --git a/lotuswordpro/source/filter/lwppara1.cxx b/lotuswordpro/source/filter/lwppara1.cxx
index cfed811..087ac0b 100644
--- a/lotuswordpro/source/filter/lwppara1.cxx
+++ b/lotuswordpro/source/filter/lwppara1.cxx
@@ -220,7 +220,7 @@ void LwpPara::GetParaNumber(sal_uInt16 nPosition, ParaNumbering* pParaNumbering)
                     if (pPreFrib)
                     {
                         if ((pPreFrib->GetType() == FRIB_TAG_TEXT) &&
-                            (pPreFrib->GetModifiers()->aTxtAttrOverride.GetHideLevels() == nHideLevels))
+                            (pPreFrib->GetModifiers() && pPreFrib->GetModifiers()->aTxtAttrOverride.GetHideLevels() == nHideLevels))
                         {
                             pParaNumbering->pPrefix = static_cast<LwpFribText*>(pPreFrib);
                         }
commit b0c826638ee55b10749f58ca9efaf7e5c4f3a25f
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Thu Dec 10 21:01:19 2015 +0000

    check for null content
    
    Change-Id: I824c29b39fe1e9e631a21f09611758bea03b0ca9
    (cherry picked from commit 4a573e67c67ddf15403a79e7ec8d984d189dc83a)

diff --git a/lotuswordpro/source/filter/lwpframelayout.cxx b/lotuswordpro/source/filter/lwpframelayout.cxx
index b26f063..8d743a0 100644
--- a/lotuswordpro/source/filter/lwpframelayout.cxx
+++ b/lotuswordpro/source/filter/lwpframelayout.cxx
@@ -912,10 +912,13 @@ bool LwpFrameLayout::IsForWaterMark()
 {
     if(m_nBuoyancy >=LAY_BUOYLAYER)
     {
-        if(!m_Content.IsNull() && (m_Content.obj()->GetTag()==VO_GRAPHIC) )
-        {
+        if (m_Content.IsNull())
+            return false;
+        rtl::Reference<LwpObject> content = m_Content.obj();
+        if (!content.is())
+            return false;
+        if (content->GetTag() == VO_GRAPHIC)
             return true;
-        }
     }
     return false;
 }
commit dca46b983000472ee6d1f74507b8421e8c817312
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Thu Dec 10 20:56:21 2015 +0000

    detect infinite recurse in object creation
    
    Change-Id: Ie56eb27bb1827860b2600a5586e866e39cd31518
    (cherry picked from commit 48c3eb3c91fd98c313bcec18f24cc949d6e788b3)

diff --git a/lotuswordpro/source/filter/lwpobjfactory.cxx b/lotuswordpro/source/filter/lwpobjfactory.cxx
index b589899..127770b 100644
--- a/lotuswordpro/source/filter/lwpobjfactory.cxx
+++ b/lotuswordpro/source/filter/lwpobjfactory.cxx
@@ -701,7 +701,12 @@ rtl::Reference<LwpObject> LwpObjectFactory::QueryObject(const LwpObjectID &objID
             return nullptr;
         }
 
+        if (std::find(m_aObjsIDInCreation.begin(), m_aObjsIDInCreation.end(), objID) != m_aObjsIDInCreation.end())
+            throw std::runtime_error("recursion in object creation");
+
+        m_aObjsIDInCreation.push_back(objID);
         obj = CreateObject(objHdr.GetTag(), objHdr);
+        m_aObjsIDInCreation.pop_back();
     }
     return obj;
 }
diff --git a/lotuswordpro/source/filter/lwpobjfactory.hxx b/lotuswordpro/source/filter/lwpobjfactory.hxx
index 426307c..6d84f5c 100644
--- a/lotuswordpro/source/filter/lwpobjfactory.hxx
+++ b/lotuswordpro/source/filter/lwpobjfactory.hxx
@@ -72,6 +72,7 @@
 #include "lwpidxmgr.hxx"
 
 #include <unordered_map>
+#include <vector>
 
 /**
  * @brief   object factory used for lwp object creation and maintenance
@@ -85,9 +86,9 @@ public:
 
 //For object Factory and object manager
 private:
-//  static LwpObjectFactory *m_pMgr;
     sal_uInt32 m_nNumObjs;
     LwpSvStream* m_pSvStream;
+    std::vector<LwpObjectID> m_aObjsIDInCreation;
     struct hashFunc
     {
             size_t operator()( const LwpObjectID& rName ) const


More information about the Libreoffice-commits mailing list