summaryrefslogtreecommitdiff
path: root/xmloff/source
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2023-04-16 20:44:25 +0100
committerCaolán McNamara <caolanm@redhat.com>2023-04-17 17:03:07 +0200
commitd405ddce1fca35e088d35805345571687c46ff5f (patch)
treea2569e0899086c2c6e2f422b6ce3a83a341f5dbd /xmloff/source
parent178832ef7139b9279a3ae0056eb11be9c476800e (diff)
crashtesting: crash on export of forum-mso-de-102589.docx to odt
recurses to death Change-Id: I4474de502df0924176cbe8d6c9244d0b73838458 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150460 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'xmloff/source')
-rw-r--r--xmloff/source/text/txtparae.cxx33
1 files changed, 28 insertions, 5 deletions
diff --git a/xmloff/source/text/txtparae.cxx b/xmloff/source/text/txtparae.cxx
index aaf47ddd4b71..1e02dbce341d 100644
--- a/xmloff/source/text/txtparae.cxx
+++ b/xmloff/source/text/txtparae.cxx
@@ -110,6 +110,7 @@
#include <iterator>
#include <officecfg/Office/Common.hxx>
#include <o3tl/safeint.hxx>
+#include <comphelper/scopeguard.hxx>
#include <comphelper/sequenceashashmap.hxx>
using namespace ::com::sun::star;
@@ -3054,17 +3055,39 @@ void XMLTextParagraphExport::exportAnyTextFrame(
if ( bExportContent )
{
Reference < XTextFrame > xTxtFrame( rTxtCntnt, UNO_QUERY );
- Reference < XText > xTxt(xTxtFrame->getText());
- exportFrameFrames( true, bIsProgress, xTxtFrame );
- exportText( xTxt, bAutoStyles, bIsProgress, true );
+ bool bAlreadySeen = !maFrameRecurseGuard.insert(xTxtFrame).second;
+ if (bAlreadySeen)
+ {
+ SAL_WARN("xmloff", "loop in frame export, ditching");
+ }
+ else
+ {
+ comphelper::ScopeGuard const g([this, xTxtFrame]() {
+ maFrameRecurseGuard.erase(xTxtFrame);
+ });
+ Reference < XText > xTxt(xTxtFrame->getText());
+ exportFrameFrames( true, bIsProgress, xTxtFrame );
+ exportText( xTxt, bAutoStyles, bIsProgress, true );
+ }
}
}
break;
case FrameType::Shape:
{
Reference < XShape > xShape( rTxtCntnt, UNO_QUERY );
- css::uno::Sequence<OUString> aAutoStylePropNames = GetAutoStylePool().GetPropertyNames();
- GetExport().GetShapeExport()->collectShapeAutoStyles( xShape, aAutoStylePropNames );
+ bool bAlreadySeen = !maShapeRecurseGuard.insert(xShape).second;
+ if (bAlreadySeen)
+ {
+ SAL_WARN("xmloff", "loop in shape export, ditching");
+ }
+ else
+ {
+ comphelper::ScopeGuard const g([this, xShape]() {
+ maShapeRecurseGuard.erase(xShape);
+ });
+ css::uno::Sequence<OUString> aAutoStylePropNames = GetAutoStylePool().GetPropertyNames();
+ GetExport().GetShapeExport()->collectShapeAutoStyles( xShape, aAutoStylePropNames );
+ }
}
break;
default: