writerfilter/source/dmapper/DomainMapper_Impl.cxx |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

New commits:
commit b2d754c49b7351f7b2663bb249b4b2f663ef3786
Author:     Justin Luth <justin.l...@collabora.com>
AuthorDate: Mon Mar 13 07:03:30 2023 -0400
Commit:     Justin Luth <jl...@mail.com>
CommitDate: Mon Mar 13 12:38:40 2023 +0000

    tdf#154129 writerfilter framePr: address nit about nSafetyLimit
    
    I was going to change --nSafetyLimit to nSafetyLimit-- anyway,
    since that better matches "getting 16 tries" like a code-reader
    would first expect (instead of only 15).
    
    I had thought about putting an assert here,
    but that isn't logically impossible to have 16 inheritances,
    so an assert seemed a bit too strict.
    But as the reviewer noted, a SAL_WARN at least ought to be here.
    
    I thought perhaps using an unordered_set might let me
    automatically eliminate loops, but then according to the documentation
    it uses "random" sorting and isn't treated like an array,
    which is definitely needed here.
    
    Of course, I could add the logic to simply check if the new
    value already exists in the vector. However, I believe that a loop
    would be considered an "invalid document" and thus should never exist,
    so clean-reading code and a safety valve against a malicious document
    seems appropriate enough to me.
    
    Change-Id: Ie6132c1beb483a6bee9c9794934ba8de7cfd82bf
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148784
    Tested-by: Justin Luth <jl...@mail.com>
    Reviewed-by: Justin Luth <jl...@mail.com>

diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx 
b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index f8cbc3c7f3f5..a63c172caf0c 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -1609,7 +1609,7 @@ void DomainMapper_Impl::CheckUnregisteredFrameConversion( 
)
         sal_Int8 nSafetyLimit = 16;
         StyleSheetEntryPtr pStyle = 
GetStyleSheetTable()->FindStyleSheetByConvertedStyleName(
             rAppendContext.pLastParagraphProperties->GetParaStyleName());
-        while (--nSafetyLimit && pStyle && pStyle->m_pProperties)
+        while (nSafetyLimit-- && pStyle && pStyle->m_pProperties)
         {
             vProps.emplace_back(&pStyle->m_pProperties->props());
             assert(pStyle->m_sBaseStyleIdentifier != pStyle->m_sStyleName);
@@ -1617,6 +1617,7 @@ void DomainMapper_Impl::CheckUnregisteredFrameConversion( 
)
                 break;
             pStyle = 
GetStyleSheetTable()->FindStyleSheetByISTD(pStyle->m_sBaseStyleIdentifier);
         }
+        SAL_WARN_IF(!nSafetyLimit,"writerfilter.dmapper","Inherited style loop 
likely: early exit");
 
         std::vector<beans::PropertyValue> aFrameProperties;
 

Reply via email to