vcl/source/fontsubset/sft.cxx |    6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

New commits:
commit bb67f10786fd5e232b198d09139c41078c3fc60d
Author:     Khaled Hosny <kha...@aliftype.com>
AuthorDate: Mon Oct 3 00:21:47 2022 +0200
Commit:     خالد حسني <kha...@aliftype.com>
CommitDate: Mon Oct 3 05:49:33 2022 +0200

    tdf#112152: Fix subsetting empty glyphs
    
    When traversing the components of composite glyphs, the code was
    treating a component pointing to an empty glyph (e.g. space) as an
    error, but it is not. An overzealous bounds check.
    
    Regression from:
    
    commit 41007842ed9bb5d6165792a197769f72dae55a2c
    Author: Martin Hosken <martin_hos...@sil.org>
    Date:   Thu Sep 10 10:14:18 2015 +0700
    
        Refactor graphite integration and update graphite
    
    Change-Id: Ie352f17cb08cd5762ff2a339662248a536b4e934
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140897
    Tested-by: Jenkins
    Reviewed-by: خالد حسني <kha...@aliftype.com>

diff --git a/vcl/source/fontsubset/sft.cxx b/vcl/source/fontsubset/sft.cxx
index 2079cefbb1a6..b51f2d3422ee 100644
--- a/vcl/source/fontsubset/sft.cxx
+++ b/vcl/source/fontsubset/sft.cxx
@@ -1460,7 +1460,7 @@ int GetTTGlyphComponents(AbstractTrueTypeFont *ttf, 
sal_uInt32 glyphID, std::vec
 
     const sal_uInt8* ptr = glyf + nOffset;
     const sal_uInt8* nptr = glyf + nNextOffset;
-    if (nptr <= ptr)
+    if (nptr < ptr)
         return 0;
 
     if (std::find(glyphlist.begin(), glyphlist.end(), glyphID) != 
glyphlist.end())
@@ -1471,6 +1471,10 @@ int GetTTGlyphComponents(AbstractTrueTypeFont *ttf, 
sal_uInt32 glyphID, std::vec
 
     glyphlist.push_back( glyphID );
 
+    // Empty glyph.
+    if (nptr == ptr)
+        return n;
+
     sal_uInt32 nRemainingData = glyflength - nOffset;
 
     if (nRemainingData >= 10 && GetInt16(ptr, 0) == -1) {

Reply via email to