sw/source/filter/ww8/ww8par.hxx  |    2 +-
 sw/source/filter/ww8/ww8par6.cxx |   17 ++++++++++++-----
 2 files changed, 13 insertions(+), 6 deletions(-)

New commits:
commit 039279d081dac9d6fe3fe80a635fcf8ce1cb8234
Author:     Caolán McNamara <caol...@redhat.com>
AuthorDate: Fri Oct 30 10:01:45 2020 +0000
Commit:     Caolán McNamara <caol...@redhat.com>
CommitDate: Fri Oct 30 15:36:34 2020 +0100

    ofz#26753 avoid infinite regress
    
    Change-Id: I3f5f14aa63c234ffdf1acd8bb730ce0ff08c7a81
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104967
    Reviewed-by: Michael Stahl <michael.st...@cib.de>
    Tested-by: Jenkins

diff --git a/sw/source/filter/ww8/ww8par.hxx b/sw/source/filter/ww8/ww8par.hxx
index 810b692ee6aa..162b6a3be255 100644
--- a/sw/source/filter/ww8/ww8par.hxx
+++ b/sw/source/filter/ww8/ww8par.hxx
@@ -1757,7 +1757,7 @@ public:     // really private, but can only be done public
 
     void SetRelativeJustify( bool bRel );
     bool IsRelativeJustify();
-    bool IsRelativeJustify( sal_uInt16 nColl );
+    bool IsRelativeJustify(sal_uInt16 nColl, o3tl::sorted_vector<sal_uInt16>& 
rVisitedStyles);
     void Read_Justify(sal_uInt16, const sal_uInt8*, short nLen);
 
     void Read_IdctHint(sal_uInt16, const sal_uInt8*, short nLen);
diff --git a/sw/source/filter/ww8/ww8par6.cxx b/sw/source/filter/ww8/ww8par6.cxx
index 99d9c22ce2ee..58e48a236238 100644
--- a/sw/source/filter/ww8/ww8par6.cxx
+++ b/sw/source/filter/ww8/ww8par6.cxx
@@ -326,7 +326,10 @@ bool SwWW8ImplReader::IsRelativeJustify()
         {
             sal_Int16 nRelative = m_vColl[m_nCurrentColl].m_nRelativeJustify;
             if ( nRelative < 0 && m_nCurrentColl )
-                bRet = IsRelativeJustify( m_vColl[m_nCurrentColl].m_nBase );
+            {
+                o3tl::sorted_vector<sal_uInt16> aVisitedStyles;
+                bRet = IsRelativeJustify(m_vColl[m_nCurrentColl].m_nBase, 
aVisitedStyles);
+            }
             else
                 bRet = nRelative > 0;
         }
@@ -334,7 +337,10 @@ bool SwWW8ImplReader::IsRelativeJustify()
         {
             sal_Int16 nRelative = m_xPlcxMan->GetPap()->nRelativeJustify;
             if ( nRelative < 0 )
-                bRet = IsRelativeJustify( m_nCurrentColl );
+            {
+                o3tl::sorted_vector<sal_uInt16> aVisitedStyles;
+                bRet = IsRelativeJustify(m_nCurrentColl, aVisitedStyles);
+            }
             else
                 bRet = nRelative > 0;
         }
@@ -343,19 +349,20 @@ bool SwWW8ImplReader::IsRelativeJustify()
     return bRet;
 }
 
-bool SwWW8ImplReader::IsRelativeJustify( sal_uInt16 nColl )
+bool SwWW8ImplReader::IsRelativeJustify(sal_uInt16 nColl, 
o3tl::sorted_vector<sal_uInt16>& rVisitedStyles)
 {
     assert( m_xWwFib->GetFIBVersion() >= ww::eWW8
         && "pointless to search styles if relative justify is impossible");
     bool bRet = true;
     if ( StyleExists(nColl) )
     {
+        rVisitedStyles.insert(nColl);
         // if relativeJustify is undefined (-1), then check the parent style.
         sal_Int16 nRelative = m_vColl[nColl].m_nRelativeJustify;
         if ( nColl == 0 || nRelative >= 0 )
             bRet = nRelative > 0;
-        else if ( nColl != m_vColl[nColl].m_nBase )
-            bRet = IsRelativeJustify( m_vColl[nColl].m_nBase );
+        else if (rVisitedStyles.find(m_vColl[nColl].m_nBase) == 
rVisitedStyles.end()) // detect loop in chain
+            bRet = IsRelativeJustify(m_vColl[nColl].m_nBase, rVisitedStyles);
     }
 
     return bRet;
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to