From 48c3eb3c91fd98c313bcec18f24cc949d6e788b3 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Thu, 10 Dec 2015 20:56:21 +0000 Subject: detect infinite recurse in object creation Change-Id: Ie56eb27bb1827860b2600a5586e866e39cd31518 --- lotuswordpro/source/filter/lwpobjfactory.cxx | 5 +++++ lotuswordpro/source/filter/lwpobjfactory.hxx | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lotuswordpro/source/filter/lwpobjfactory.cxx b/lotuswordpro/source/filter/lwpobjfactory.cxx index b58989908155..127770bd8d5d 100644 --- a/lotuswordpro/source/filter/lwpobjfactory.cxx +++ b/lotuswordpro/source/filter/lwpobjfactory.cxx @@ -701,7 +701,12 @@ rtl::Reference 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 426307c8251e..6d84f5c0d31f 100644 --- a/lotuswordpro/source/filter/lwpobjfactory.hxx +++ b/lotuswordpro/source/filter/lwpobjfactory.hxx @@ -72,6 +72,7 @@ #include "lwpidxmgr.hxx" #include +#include /** * @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 m_aObjsIDInCreation; struct hashFunc { size_t operator()( const LwpObjectID& rName ) const -- cgit