[Libreoffice-commits] core.git: lotuswordpro/source

Caolán McNamara caolanm at redhat.com
Wed Dec 9 13:32:57 PST 2015


 lotuswordpro/source/filter/lwp9reader.cxx     |    2 +-
 lotuswordpro/source/filter/lwpcelllayout.cxx  |    2 +-
 lotuswordpro/source/filter/lwpdoc.cxx         |   10 +++++-----
 lotuswordpro/source/filter/lwpfnlayout.cxx    |    4 ++--
 lotuswordpro/source/filter/lwpfootnote.cxx    |    2 +-
 lotuswordpro/source/filter/lwpfoundry.cxx     |    8 ++++----
 lotuswordpro/source/filter/lwpframelayout.cxx |    2 +-
 lotuswordpro/source/filter/lwpfribframe.cxx   |    2 +-
 lotuswordpro/source/filter/lwplayout.cxx      |    2 +-
 lotuswordpro/source/filter/lwpnotes.cxx       |    6 +++---
 lotuswordpro/source/filter/lwpobj.cxx         |    2 +-
 lotuswordpro/source/filter/lwpobj.hxx         |   13 ++++++++++++-
 lotuswordpro/source/filter/lwppagelayout.cxx  |    4 ++--
 lotuswordpro/source/filter/lwpvpointer.cxx    |    2 +-
 14 files changed, 36 insertions(+), 25 deletions(-)

New commits:
commit 66686e443b568ad5aab1b32b3f25eb73487cfef6
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Wed Dec 9 21:32:21 2015 +0000

    guard against infinite recursion on registering styles
    
    Change-Id: Iabedfcce9d8ef21172e6bd0d654f3a258aae97e3

diff --git a/lotuswordpro/source/filter/lwp9reader.cxx b/lotuswordpro/source/filter/lwp9reader.cxx
index c9267e8..e7c670a 100644
--- a/lotuswordpro/source/filter/lwp9reader.cxx
+++ b/lotuswordpro/source/filter/lwp9reader.cxx
@@ -148,7 +148,7 @@ void Lwp9Reader::ParseDocument()
 
     //Register Styles
     RegisteArrowStyles();
-    doc->RegisterStyle();
+    doc->DoRegisterStyle();
     XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
     pXFStyleManager->ToXml(m_pStream);
 
diff --git a/lotuswordpro/source/filter/lwpcelllayout.cxx b/lotuswordpro/source/filter/lwpcelllayout.cxx
index 635e486..f630a01 100644
--- a/lotuswordpro/source/filter/lwpcelllayout.cxx
+++ b/lotuswordpro/source/filter/lwpcelllayout.cxx
@@ -597,7 +597,7 @@ void LwpCellLayout::RegisterStyle()
     if (pObj.is())
     {
         pObj->SetFoundry(m_pFoundry);
-        pObj->RegisterStyle();
+        pObj->DoRegisterStyle();
     }
 
     //register child layout style
diff --git a/lotuswordpro/source/filter/lwpdoc.cxx b/lotuswordpro/source/filter/lwpdoc.cxx
index b93f44d..a343f9c 100644
--- a/lotuswordpro/source/filter/lwpdoc.cxx
+++ b/lotuswordpro/source/filter/lwpdoc.cxx
@@ -224,7 +224,7 @@ void LwpDocument::RegisterStyle()
     rtl::Reference<LwpObject> pDocSock = GetSocket().obj();
     if(pDocSock.is())
     {
-        pDocSock->RegisterStyle();
+        pDocSock->DoRegisterStyle();
     }
 }
 /**
@@ -322,7 +322,7 @@ void LwpDocument::RegisterGraphicsStyles()
     if(pGraphic.is())
     {
         pGraphic->SetFoundry(m_pFoundry);
-        pGraphic->RegisterStyle();
+        pGraphic->DoRegisterStyle();
     }
 }
 /**
@@ -619,7 +619,7 @@ LwpDocument* LwpDocument::GetPreviousDivision()
 
     LwpDocument* pDivision = GetFirstDivision();
 
-    while (pDivision)
+    while (pDivision && pDivision != this)
     {
         LwpDocument* pContentDivision = pDivision->GetFirstDivisionWithContentsThatIsNotOLE();
         if(pContentDivision)
@@ -782,11 +782,11 @@ void LwpDocSock::RegisterStyle()
 {
     rtl::Reference<LwpObject> pDoc = GetNext().obj();
     if(pDoc.is())
-        pDoc->RegisterStyle();
+        pDoc->DoRegisterStyle();
 
     pDoc = GetChildHead().obj();
     if(pDoc.is())
-        pDoc->RegisterStyle();
+        pDoc->DoRegisterStyle();
 }
  /**
  * @descr    parse contents of documents plugged
diff --git a/lotuswordpro/source/filter/lwpfnlayout.cxx b/lotuswordpro/source/filter/lwpfnlayout.cxx
index cfbbaaa..7707eef 100644
--- a/lotuswordpro/source/filter/lwpfnlayout.cxx
+++ b/lotuswordpro/source/filter/lwpfnlayout.cxx
@@ -160,7 +160,7 @@ void LwpFnCellLayout::RegisterStyle()
     if (pObj.is())
     {
         pObj->SetFoundry(m_pFoundry);
-        pObj->RegisterStyle();
+        pObj->DoRegisterStyle();
     }
 }
 
@@ -237,7 +237,7 @@ void LwpEnSuperTableLayout::RegisterStyle()
     if (pTableLayout != nullptr)
     {
         pTableLayout->SetFoundry(m_pFoundry);
-        pTableLayout->RegisterStyle();
+        pTableLayout->DoRegisterStyle();
     }
 }
 
diff --git a/lotuswordpro/source/filter/lwpfootnote.cxx b/lotuswordpro/source/filter/lwpfootnote.cxx
index b57a3a7..49b6083 100644
--- a/lotuswordpro/source/filter/lwpfootnote.cxx
+++ b/lotuswordpro/source/filter/lwpfootnote.cxx
@@ -174,7 +174,7 @@ void LwpFootnote::RegisterStyle()
         if(pContent)
         {
             pContent->SetFoundry(m_pFoundry);
-            pContent->RegisterStyle();
+            pContent->DoRegisterStyle();
         }
     }
 }
diff --git a/lotuswordpro/source/filter/lwpfoundry.cxx b/lotuswordpro/source/filter/lwpfoundry.cxx
index b25e2dd..64897e2 100644
--- a/lotuswordpro/source/filter/lwpfoundry.cxx
+++ b/lotuswordpro/source/filter/lwpfoundry.cxx
@@ -188,7 +188,7 @@ void LwpFoundry::RegisterAllLayouts()
     if( pStyle.is() )
     {
         pStyle->SetFoundry(this);
-        pStyle->RegisterStyle();
+        pStyle->DoRegisterStyle();
     }
 
     //register content page layout list: Layout
@@ -196,7 +196,7 @@ void LwpFoundry::RegisterAllLayouts()
     if( pStyle.is() )
     {
         pStyle->SetFoundry(this);
-        pStyle->RegisterStyle();
+        pStyle->DoRegisterStyle();
     }
 
     //Register page style layout list: PageStyle, such as "Default Page"
@@ -204,7 +204,7 @@ void LwpFoundry::RegisterAllLayouts()
     if( pStyle.is() )
     {
         pStyle->SetFoundry(this);
-        pStyle->RegisterStyle();
+        pStyle->DoRegisterStyle();
     }
 
     //Register FrameStyle
@@ -212,7 +212,7 @@ void LwpFoundry::RegisterAllLayouts()
     if( pStyle.is() )
     {
         pStyle->SetFoundry(this);
-        pStyle->RegisterStyle();
+        pStyle->DoRegisterStyle();
     }
 
 }
diff --git a/lotuswordpro/source/filter/lwpframelayout.cxx b/lotuswordpro/source/filter/lwpframelayout.cxx
index 80143ff..996673de 100644
--- a/lotuswordpro/source/filter/lwpframelayout.cxx
+++ b/lotuswordpro/source/filter/lwpframelayout.cxx
@@ -862,7 +862,7 @@ void  LwpFrameLayout::RegisterStyle()
     if (content.is())
     {
         content->SetFoundry(m_pFoundry);
-        content->RegisterStyle();
+        content->DoRegisterStyle();
     }
 
     //register child frame style
diff --git a/lotuswordpro/source/filter/lwpfribframe.cxx b/lotuswordpro/source/filter/lwpfribframe.cxx
index 744559e..9f039c9 100644
--- a/lotuswordpro/source/filter/lwpfribframe.cxx
+++ b/lotuswordpro/source/filter/lwpfribframe.cxx
@@ -102,7 +102,7 @@ void LwpFribFrame::RegisterStyle(LwpFoundry* pFoundry)
         if (!pLayout)
             return;
         pLayout->SetFoundry(pFoundry);
-        pLayout->RegisterStyle();
+        pLayout->DoRegisterStyle();
 
         //register next frib text style
         sal_uInt8 nType = pLayout->GetRelativeType();
diff --git a/lotuswordpro/source/filter/lwplayout.cxx b/lotuswordpro/source/filter/lwplayout.cxx
index 7c8aff0..5fa4e2c 100644
--- a/lotuswordpro/source/filter/lwplayout.cxx
+++ b/lotuswordpro/source/filter/lwplayout.cxx
@@ -486,7 +486,7 @@ void LwpHeadLayout::RegisterStyle()
                 OSL_FAIL("Layout points to itself");
                 break;
             }
-            pLayout->RegisterStyle();
+            pLayout->DoRegisterStyle();
         }
         LwpVirtualLayout *pNext = dynamic_cast<LwpVirtualLayout*>(pLayout->GetNext().obj().get());
         if (pNext == pLayout)
diff --git a/lotuswordpro/source/filter/lwpnotes.cxx b/lotuswordpro/source/filter/lwpnotes.cxx
index 854d46b..7b2221a 100644
--- a/lotuswordpro/source/filter/lwpnotes.cxx
+++ b/lotuswordpro/source/filter/lwpnotes.cxx
@@ -89,7 +89,7 @@ void LwpFribNote::RegisterNewStyle()
         LwpFrib::RegisterStyle(m_pPara->GetFoundry());
         //register foonote style
         pLayout->SetFoundry(m_pPara->GetFoundry());
-        pLayout->RegisterStyle();
+        pLayout->DoRegisterStyle();
     }
 }
 
@@ -169,7 +169,7 @@ void LwpNoteLayout::RegisterStyle()
     if(pTextLayout)
     {
         pTextLayout->SetFoundry(GetFoundry());
-        pTextLayout->RegisterStyle();
+        pTextLayout->DoRegisterStyle();
     }
 }
 
@@ -281,7 +281,7 @@ void LwpNoteTextLayout::RegisterStyle()
     if(pContent.is())
     {
         pContent->SetFoundry(GetFoundry());
-        pContent->RegisterStyle();
+        pContent->DoRegisterStyle();
     }
 }
 
diff --git a/lotuswordpro/source/filter/lwpobj.cxx b/lotuswordpro/source/filter/lwpobj.cxx
index d8e44f6..e049a82 100644
--- a/lotuswordpro/source/filter/lwpobj.cxx
+++ b/lotuswordpro/source/filter/lwpobj.cxx
@@ -60,7 +60,7 @@
  * @descr  construct lwpobject from stream
  */
 LwpObject::LwpObject(LwpObjectHeader objHdr, LwpSvStream* pStrm)
-    : m_ObjHdr(objHdr), m_pObjStrm(nullptr), m_pFoundry(nullptr), m_pStrm(pStrm)
+    : m_ObjHdr(objHdr), m_pObjStrm(nullptr), m_pFoundry(nullptr), m_pStrm(pStrm), m_bRegisteringStyle(false)
 {
     m_pObjStrm = new LwpObjectStream(pStrm, m_ObjHdr.IsCompressed(),
             static_cast<sal_uInt16>(m_ObjHdr.GetSize()) );
diff --git a/lotuswordpro/source/filter/lwpobj.hxx b/lotuswordpro/source/filter/lwpobj.hxx
index 87cdc78..0dc2d97 100644
--- a/lotuswordpro/source/filter/lwpobj.hxx
+++ b/lotuswordpro/source/filter/lwpobj.hxx
@@ -88,11 +88,22 @@ protected:
     LwpObjectStream* m_pObjStrm;
     LwpFoundry* m_pFoundry;
     LwpSvStream* m_pStrm;
+    bool m_bRegisteringStyle;
 protected:
     virtual void Read();
+    virtual void RegisterStyle();
 public:
     void QuickRead();
-    virtual void RegisterStyle();
+    //calls RegisterStyle but bails if DoRegisterStyle is called
+    //on the same object recursively
+    void DoRegisterStyle()
+    {
+        if (m_bRegisteringStyle)
+            throw std::runtime_error("recursion in styles");
+        m_bRegisteringStyle = true;
+        RegisterStyle();
+        m_bRegisteringStyle = false;
+    }
     virtual void Parse(IXFStream* pOutputStream);
     virtual void XFConvert(XFContentContainer* pCont);
 
diff --git a/lotuswordpro/source/filter/lwppagelayout.cxx b/lotuswordpro/source/filter/lwppagelayout.cxx
index 4bd134b..8499126 100644
--- a/lotuswordpro/source/filter/lwppagelayout.cxx
+++ b/lotuswordpro/source/filter/lwppagelayout.cxx
@@ -881,7 +881,7 @@ void LwpHeaderLayout::RegisterStyle(XFMasterPage* mp1)
 
         //Call the RegisterStyle first to register the styles in header paras, and then XFConvert()
         pStory->SetFoundry(m_pFoundry);
-        pStory->RegisterStyle();
+        pStory->DoRegisterStyle();
         //, 06/27/2005
         //register child layout style for framelayout,
         RegisterChildStyle();
@@ -1034,7 +1034,7 @@ void LwpFooterLayout::RegisterStyle(XFMasterPage* mp1)
         pChangeMgr->SetHeadFootFribMap(true);
 
         pStory->SetFoundry(m_pFoundry);
-        pStory->RegisterStyle();
+        pStory->DoRegisterStyle();
         //register child layout style for framelayout,
         RegisterChildStyle();
 
diff --git a/lotuswordpro/source/filter/lwpvpointer.cxx b/lotuswordpro/source/filter/lwpvpointer.cxx
index 796e0d4..9d1a7dc 100644
--- a/lotuswordpro/source/filter/lwpvpointer.cxx
+++ b/lotuswordpro/source/filter/lwpvpointer.cxx
@@ -77,7 +77,7 @@ void LwpVersionedPointer::RegisterStyle()
     if( pObj.is() )
     {
         pObj->SetFoundry(m_pFoundry);
-        pObj->RegisterStyle();
+        pObj->DoRegisterStyle();
     }
 }
 


More information about the Libreoffice-commits mailing list