vcl/source/fontsubset/sft.cxx |   13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

New commits:
commit 8db43afcfc0aaff7059ae57022b53d492f1c806a
Author:     Caolán McNamara <caol...@redhat.com>
AuthorDate: Wed Mar 2 10:13:53 2022 +0000
Commit:     Caolán McNamara <caol...@redhat.com>
CommitDate: Thu Mar 3 12:28:13 2022 +0100

    ofz: detect endless loop in font processing
    
    Change-Id: I4e6c61d8be15a560f43b5d37d646e7bad9739eb7
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130779
    Reviewed-by: Michael Stahl <michael.st...@allotropia.de>
    Tested-by: Jenkins

diff --git a/vcl/source/fontsubset/sft.cxx b/vcl/source/fontsubset/sft.cxx
index 7ebe3cbe8cc3..124b4f249655 100644
--- a/vcl/source/fontsubset/sft.cxx
+++ b/vcl/source/fontsubset/sft.cxx
@@ -541,9 +541,9 @@ static int GetCompoundTTOutline(AbstractTrueTypeFont *ttf, 
sal_uInt32 glyphID, C
 
         if( std::find( glyphlist.begin(), glyphlist.end(), index ) != 
glyphlist.end() )
         {
-#if OSL_DEBUG_LEVEL > 1
-            SAL_INFO("vcl.fonts", "Endless loop found in a compound glyph.");
+            SAL_WARN("vcl.fonts", "Endless loop found in a compound glyph.");
 
+#if OSL_DEBUG_LEVEL > 1
             std::ostringstream oss;
             oss << index << " -> [";
             for( const auto& rGlyph : glyphlist )
@@ -554,6 +554,7 @@ static int GetCompoundTTOutline(AbstractTrueTypeFont *ttf, 
sal_uInt32 glyphID, C
             SAL_INFO("vcl.fonts", oss.str());
         /**/
 #endif
+            return 0;
         }
 
         glyphlist.push_back( index );
@@ -561,10 +562,8 @@ static int GetCompoundTTOutline(AbstractTrueTypeFont *ttf, 
sal_uInt32 glyphID, C
         if ((np = GetTTGlyphOutline(ttf, index, &nextComponent, nullptr, 
&glyphlist)) == 0)
         {
             /* XXX that probably indicates a corrupted font */
-#if OSL_DEBUG_LEVEL > 1
             SAL_WARN("vcl.fonts", "An empty compound!");
             /* assert(!"An empty compound"); */
-#endif
         }
 
         if( ! glyphlist.empty() )
@@ -1453,6 +1452,12 @@ int GetTTGlyphComponents(AbstractTrueTypeFont *ttf, 
sal_uInt32 glyphID, std::vec
     if (nptr <= ptr)
         return 0;
 
+    if (std::find(glyphlist.begin(), glyphlist.end(), glyphID) != 
glyphlist.end())
+    {
+        SAL_WARN("vcl.fonts", "Endless loop found in a compound glyph.");
+        return 0;
+    }
+
     glyphlist.push_back( glyphID );
 
     const sal_uInt32 nMaxGlyphSize = glyflength - nOffset;

Reply via email to