summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2016-03-08 12:09:55 +0000
committerMiklos Vajna <vmiklos@collabora.co.uk>2016-03-09 14:20:40 +0000
commite1cb3aa56b94fdf75b775e42fe4b039be82b8d32 (patch)
treeb6be18b2ddd961b0e0392c9cc143bdd6994b04e0
parent4daf0fde2452e640275d3c4baa1c4abae97f3b43 (diff)
avoid infinite regress in busted documents
Change-Id: I639617e41cd9a9a51a3dd3efa32ac1cf2991b9d2 (cherry picked from commit f16ceae46dd8f3974a379c6fb07feaffb8012b25) Reviewed-on: https://gerrit.libreoffice.org/23030 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
-rw-r--r--lotuswordpro/qa/cppunit/data/fail/loop-2.lwpbin0 -> 79446 bytes
-rw-r--r--lotuswordpro/source/filter/lwpdivinfo.cxx8
-rw-r--r--lotuswordpro/source/filter/lwpfont.cxx2
-rw-r--r--lotuswordpro/source/filter/lwptablelayout.cxx4
-rw-r--r--lotuswordpro/source/filter/lwptblformula.cxx2
-rw-r--r--lotuswordpro/source/filter/xfilter/xfcontent.hxx21
-rw-r--r--lotuswordpro/source/filter/xfilter/xfcontentcontainer.cxx2
-rw-r--r--lotuswordpro/source/filter/xfilter/xftextspan.cxx6
8 files changed, 28 insertions, 17 deletions
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 000000000000..6342cc56ef4c
--- /dev/null
+++ b/lotuswordpro/qa/cppunit/data/fail/loop-2.lwp
Binary files differ
diff --git a/lotuswordpro/source/filter/lwpdivinfo.cxx b/lotuswordpro/source/filter/lwpdivinfo.cxx
index 2f9a6cf60e41..efa32f69561a 100644
--- a/lotuswordpro/source/filter/lwpdivinfo.cxx
+++ b/lotuswordpro/source/filter/lwpdivinfo.cxx
@@ -108,15 +108,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 5e0d2749dc3b..8805533ba181 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 4efa6a824db4..3357ac1f988a 100644
--- a/lotuswordpro/source/filter/lwptablelayout.cxx
+++ b/lotuswordpro/source/filter/lwptablelayout.cxx
@@ -215,13 +215,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 6f699c53fa92..7a28a6ed53c7 100644
--- a/lotuswordpro/source/filter/lwptblformula.cxx
+++ b/lotuswordpro/source/filter/lwptblformula.cxx
@@ -342,7 +342,7 @@ void LwpFormulaInfo::Read()
}
else
{
- assert(false);
+ SAL_WARN("lwp", "missing row list");
}
}
m_pObjStrm->SeekRel(2);//flags, size in file: sal_uInt16
diff --git a/lotuswordpro/source/filter/xfilter/xfcontent.hxx b/lotuswordpro/source/filter/xfilter/xfcontent.hxx
index 2d1dfa7e7b15..29a2fd070e6e 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 05a24f948f33..7608da24307f 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 4de6bad98df7..90f6e32aa569 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" );
}