summaryrefslogtreecommitdiff
path: root/vcl/source
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2022-03-02 10:13:53 +0000
committerCaolán McNamara <caolanm@redhat.com>2022-03-04 12:11:18 +0100
commit25043c5f18cefe6603e4aa084823b810d8a62485 (patch)
treee46a15b26159f96c3481c149fa754590c6aee0d9 /vcl/source
parent019ab8e3c112bafa841f19cf1ef2ef09845efda5 (diff)
ofz: detect endless loop in font processing
Change-Id: I4e6c61d8be15a560f43b5d37d646e7bad9739eb7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130778 Reviewed-by: Michael Stahl <michael.stahl@allotropia.de> Tested-by: Jenkins
Diffstat (limited to 'vcl/source')
-rw-r--r--vcl/source/fontsubset/sft.cxx13
1 files changed, 9 insertions, 4 deletions
diff --git a/vcl/source/fontsubset/sft.cxx b/vcl/source/fontsubset/sft.cxx
index 5f85c1b30673..8084bb247567 100644
--- a/vcl/source/fontsubset/sft.cxx
+++ b/vcl/source/fontsubset/sft.cxx
@@ -568,9 +568,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 )
@@ -581,6 +581,7 @@ static int GetCompoundTTOutline(AbstractTrueTypeFont *ttf, sal_uInt32 glyphID, C
SAL_INFO("vcl.fonts", oss.str());
/**/
#endif
+ return 0;
}
glyphlist.push_back( index );
@@ -588,10 +589,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() )
@@ -1513,6 +1512,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 );
sal_uInt32 nRemainingData = glyflength - nOffset;