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

Caolán McNamara caolanm at redhat.com
Wed Mar 9 14:36:11 UTC 2016


 lotuswordpro/qa/cppunit/data/fail/loop-2.lwp              |binary
 lotuswordpro/source/filter/lwpdivinfo.cxx                 |    8 +----
 lotuswordpro/source/filter/lwpfont.cxx                    |    2 -
 lotuswordpro/source/filter/lwptablelayout.cxx             |    4 +-
 lotuswordpro/source/filter/lwptblformula.cxx              |    2 -
 lotuswordpro/source/filter/xfilter/xfcontent.hxx          |   21 ++++++++++++--
 lotuswordpro/source/filter/xfilter/xfcontentcontainer.cxx |    2 -
 lotuswordpro/source/filter/xfilter/xftextspan.cxx         |    6 ++--
 8 files changed, 28 insertions(+), 17 deletions(-)

New commits:
commit 69e4ce0716f7998dbeab954a43b912e72f0f4947
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Tue Mar 8 12:09:55 2016 +0000

    avoid infinite regress in busted documents
    
    Change-Id: I639617e41cd9a9a51a3dd3efa32ac1cf2991b9d2
    (cherry picked from commit f16ceae46dd8f3974a379c6fb07feaffb8012b25)
    Reviewed-on: https://gerrit.libreoffice.org/23031
    Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>
    Tested-by: Miklos Vajna <vmiklos at collabora.co.uk>

diff --git a/lotuswordpro/qa/cppunit/data/fail/loop-2.lwp b/lotuswordpro/qa/cppunit/data/fail/loop-2.lwp
new file mode 100644
index 0000000..6342cc5
Binary files /dev/null and b/lotuswordpro/qa/cppunit/data/fail/loop-2.lwp differ
diff --git a/lotuswordpro/source/filter/lwpdivinfo.cxx b/lotuswordpro/source/filter/lwpdivinfo.cxx
index 11d4f0e..80884f7 100644
--- a/lotuswordpro/source/filter/lwpdivinfo.cxx
+++ b/lotuswordpro/source/filter/lwpdivinfo.cxx
@@ -112,15 +112,11 @@ void LwpDivInfo::Read()
     m_FillerPageTextID.ReadIndexed(m_pObjStrm);
 
     // read external file object stuff
-#if !defined(NDEBUG)
-    sal_uInt16 type =
-#endif
-    m_pObjStrm->QuickReaduInt16();
+    sal_uInt16 type = m_pObjStrm->QuickReaduInt16();
     //cpExternalFile = LNULL;
 
-    assert(type==0);
+    SAL_WARN_IF(type != 0, "lwp", "should be 0");
     m_pObjStrm->SkipExtra();
-
 }
 
 void LwpDivInfo::SkipFront()
diff --git a/lotuswordpro/source/filter/lwpfont.cxx b/lotuswordpro/source/filter/lwpfont.cxx
index 4307d29..79e94bf 100644
--- a/lotuswordpro/source/filter/lwpfont.cxx
+++ b/lotuswordpro/source/filter/lwpfont.cxx
@@ -262,7 +262,7 @@ void LwpFontTable::Read(LwpObjectStream *pStrm)
 
 OUString LwpFontTable::GetFaceName(sal_uInt16 index) //index: start from 1
 {
-    assert(index <= m_nCount && index > 0);
+    SAL_WARN_IF(index > m_nCount || index <= 0, "lwp", "bad font index");
     return (index <= m_nCount && index > 0) ? m_pFontEntries[index-1].GetFaceName() : OUString();
 }
 
diff --git a/lotuswordpro/source/filter/lwptablelayout.cxx b/lotuswordpro/source/filter/lwptablelayout.cxx
index 6f1b73c..ec18542 100644
--- a/lotuswordpro/source/filter/lwptablelayout.cxx
+++ b/lotuswordpro/source/filter/lwptablelayout.cxx
@@ -218,13 +218,13 @@ double LwpSuperTableLayout::GetTableWidth()
         LwpTableLayout* pTableLayout = GetTableLayout();
         if(!pTableLayout)
         {
-            assert(false);
+            SAL_WARN("lwp", "missing table layout, early return");
             return 0;
         }
         LwpTable *pTable = pTableLayout->GetTable();
         if(!pTable)
         {
-            assert(false);
+            SAL_WARN("lwp", "missing table, early return");
             return 0;
         }
         double dDefaultWidth = pTable->GetWidth();
diff --git a/lotuswordpro/source/filter/lwptblformula.cxx b/lotuswordpro/source/filter/lwptblformula.cxx
index 7f8ea4a..699b7ce 100644
--- a/lotuswordpro/source/filter/lwptblformula.cxx
+++ b/lotuswordpro/source/filter/lwptblformula.cxx
@@ -389,7 +389,7 @@ void LwpFormulaInfo::Read()
         }
         else
         {
-            assert(false);
+            SAL_WARN("lwp", "missing row list");
         }
     }
 //  sal_uInt8 cFlags = (sal_uInt8) m_pObjStrm->QuickReaduInt16(); // written as a sal_uInt16
diff --git a/lotuswordpro/source/filter/xfilter/xfcontent.hxx b/lotuswordpro/source/filter/xfilter/xfcontent.hxx
index 2d1dfa7..29a2fd0 100644
--- a/lotuswordpro/source/filter/xfilter/xfcontent.hxx
+++ b/lotuswordpro/source/filter/xfilter/xfcontent.hxx
@@ -64,6 +64,7 @@
 
 #include <rtl/ustring.hxx>
 #include <salhelper/simplereferenceobject.hxx>
+#include <stdexcept>
 
 #include "xfdefs.hxx"
 
@@ -92,14 +93,28 @@ public:
      */
     OUString   GetStyleName() {return m_strStyleName;}
 
-    virtual void ToXml(IXFStream * stream) = 0;
+    void DoToXml(IXFStream* stream)
+    {
+        if (m_bDoingToXml)
+            throw std::runtime_error("recursion in content");
+        m_bDoingToXml = true;
+        ToXml(stream);
+        m_bDoingToXml = false;
+    }
 
 protected:
-    XFContent() {}
+    XFContent()
+        : m_bDoingToXml(false)
+    {
+    }
+
+    virtual void ToXml(IXFStream* stream) = 0;
 
     virtual ~XFContent() {}
 
-    OUString   m_strStyleName;
+    OUString m_strStyleName;
+private:
+    bool m_bDoingToXml;
 };
 
 #endif
diff --git a/lotuswordpro/source/filter/xfilter/xfcontentcontainer.cxx b/lotuswordpro/source/filter/xfilter/xfcontentcontainer.cxx
index ece407e..4e3576d 100644
--- a/lotuswordpro/source/filter/xfilter/xfcontentcontainer.cxx
+++ b/lotuswordpro/source/filter/xfilter/xfcontentcontainer.cxx
@@ -131,7 +131,7 @@ void    XFContentContainer::ToXml(IXFStream *pStrm)
     {
         XFContent *pContent = it->get();
         if( pContent )
-            pContent->ToXml(pStrm);
+            pContent->DoToXml(pStrm);
     }
 }
 
diff --git a/lotuswordpro/source/filter/xfilter/xftextspan.cxx b/lotuswordpro/source/filter/xfilter/xftextspan.cxx
index 4de6bad..90f6e32 100644
--- a/lotuswordpro/source/filter/xfilter/xftextspan.cxx
+++ b/lotuswordpro/source/filter/xfilter/xftextspan.cxx
@@ -112,7 +112,7 @@ void    XFTextSpan::ToXml(IXFStream *pStrm)
     {
         XFContent *pContent = it->get();
         if( pContent )
-            pContent->ToXml(pStrm);
+            pContent->DoToXml(pStrm);
     }
 
     pStrm->EndElement( "text:span" );
@@ -135,7 +135,7 @@ void    XFTextSpanStart::ToXml(IXFStream *pStrm)
     {
         XFContent *pContent = it->get();
         if( pContent )
-            pContent->ToXml(pStrm);
+            pContent->DoToXml(pStrm);
     }
 }
 void    XFTextSpanEnd::ToXml(IXFStream *pStrm)
@@ -145,7 +145,7 @@ void    XFTextSpanEnd::ToXml(IXFStream *pStrm)
     {
         XFContent *pContent = it->get();
         if( pContent )
-            pContent->ToXml(pStrm);
+            pContent->DoToXml(pStrm);
     }
     pStrm->EndElement( "text:span" );
 }


More information about the Libreoffice-commits mailing list