From f96dc71b49aee05800cb137671abcbded237c77f Mon Sep 17 00:00:00 2001 From: Uwe Rathmann Date: Mon, 10 Feb 2025 14:38:18 +0100 Subject: [PATCH] avoid crash with incomplete font definitions ( IcoMoon ) --- src/graphic/QskGlyphTable.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/graphic/QskGlyphTable.cpp b/src/graphic/QskGlyphTable.cpp index ca6cccca..c5e63bcb 100644 --- a/src/graphic/QskGlyphTable.cpp +++ b/src/graphic/QskGlyphTable.cpp @@ -50,15 +50,18 @@ namespace PostTableParser const auto from = reinterpret_cast< const uint8_t* >( glyphData + nglyphs ); const auto to = reinterpret_cast< const uint8_t* >( blob.data() + blob.size() ); - for ( auto s = from; s < to; s += *s + 1 ) - strings += s; - - for ( int i = 0; i < nglyphs; i++ ) + if ( to > from ) { - const int idx = qFromBigEndian( glyphData[i] ) - 258; + for ( auto s = from; s < to; s += *s + 1 ) + strings += s; - if ( idx >= 0 ) - names.insert( toString( strings[idx] ), i ); + for ( int i = 0; i < nglyphs; i++ ) + { + const int idx = qFromBigEndian( glyphData[i] ) - 258; + + if ( idx >= 0 && idx < strings.size() ) + names.insert( toString( strings[idx] ), i ); + } } }