vcl/source/gdi/CommonSalLayout.cxx |    8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

New commits:
commit 2c2b3aaa5ba15087aac06b762cc4b767eaea6cac
Author:     Caolán McNamara <[email protected]>
AuthorDate: Thu Mar 17 16:12:20 2022 +0000
Commit:     Caolán McNamara <[email protected]>
CommitDate: Thu Mar 17 22:16:50 2022 +0100

    crashtesting: clip fallback glyph range to layout range
    
    as seen in tdf124116-1.odt
    
    Change-Id: If81192d326e298794051a87632e63798402ff60b
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131712
    Tested-by: Jenkins
    Tested-by: Julien Nabet <[email protected]>
    Reviewed-by: Caolán McNamara <[email protected]>

diff --git a/vcl/source/gdi/CommonSalLayout.cxx 
b/vcl/source/gdi/CommonSalLayout.cxx
index c4217e21a985..74478e0ef268 100644
--- a/vcl/source/gdi/CommonSalLayout.cxx
+++ b/vcl/source/gdi/CommonSalLayout.cxx
@@ -224,15 +224,19 @@ void 
GenericSalLayout::SetNeedFallback(vcl::text::ImplLayoutArgs& rArgs, sal_Int
     //mark all glyphs as missing so the whole thing is rendered with the same
     //font
     sal_Int32 nDone;
-    sal_Int32 nGraphemeEndPos =
+    int nGraphemeEndPos =
         mxBreak->nextCharacters(rArgs.mrStr, nCharPos, aLocale,
             i18n::CharacterIteratorMode::SKIPCELL, 1, nDone);
     // Safely advance nCharPos in case it is a non-BMP character.
     rArgs.mrStr.iterateCodePoints(&nCharPos);
-    sal_Int32 nGraphemeStartPos =
+    int nGraphemeStartPos =
         mxBreak->previousCharacters(rArgs.mrStr, nCharPos, aLocale,
             i18n::CharacterIteratorMode::SKIPCELL, 1, nDone);
 
+    //stay inside the Layout range (e.g. with tdf124116-1.odt)
+    nGraphemeStartPos = std::max(rArgs.mnMinCharPos, nGraphemeStartPos);
+    nGraphemeEndPos = std::min(rArgs.mnEndCharPos, nGraphemeEndPos);
+
     rArgs.AddFallbackRun(nGraphemeStartPos, nGraphemeEndPos, bRightToLeft);
 }
 

Reply via email to