diff options
author | Caolán McNamara <caolanm@redhat.com> | 2022-02-28 21:12:07 +0000 |
---|---|---|
committer | Thorsten Behrens <thorsten.behrens@allotropia.de> | 2022-03-02 22:27:18 +0100 |
commit | 33935f3968da8e83874b64c8e17e2d818fcf1ff4 (patch) | |
tree | b892cbf2ebdda7f61747bf29853c414a2767fa7a | |
parent | 2c1382a4e41fd5a9a6617685c210f2f74f7913cb (diff) |
ofz: measure maximum possible contours
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130774
Tested-by: Jenkins
Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
(cherry picked from commit 26abdb564dad2011a298fc1253279232cb8b59cf)
Change-Id: Ie039abd835fef06514edde12b99e17360f5481a5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130873
Tested-by: Thorsten Behrens <thorsten.behrens@allotropia.de>
Reviewed-by: Thorsten Behrens <thorsten.behrens@allotropia.de>
-rw-r--r-- | vcl/source/fontsubset/sft.cxx | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/vcl/source/fontsubset/sft.cxx b/vcl/source/fontsubset/sft.cxx index 2d2157f6f675..8a684e472e0a 100644 --- a/vcl/source/fontsubset/sft.cxx +++ b/vcl/source/fontsubset/sft.cxx @@ -362,7 +362,13 @@ static int GetSimpleTTOutline(TrueTypeFont const *ttf, sal_uInt32 glyphID, Contr if( glyphID >= ttf->nglyphs ) /*- glyph is not present in the font */ return 0; - const sal_uInt8* ptr = table + ttf->goffsets[glyphID]; + sal_uInt32 nGlyphOffset = ttf->goffsets[glyphID]; + if (nGlyphOffset > nTableSize) + return 0; + + const sal_uInt8* ptr = table + nGlyphOffset; + const sal_uInt32 nMaxGlyphSize = nTableSize - nGlyphOffset; + const sal_Int16 numberOfContours = GetInt16(ptr, GLYF_numberOfContours_offset); if( numberOfContours <= 0 ) /*- glyph is not simple */ return 0; @@ -377,7 +383,7 @@ static int GetSimpleTTOutline(TrueTypeFont const *ttf, sal_uInt32 glyphID, Contr /* determine the last point and be extra safe about it. But probably this code is not needed */ sal_uInt16 lastPoint=0; - const sal_Int32 nMaxContours = (nTableSize - 10)/2; + const sal_Int32 nMaxContours = (nMaxGlyphSize - 10)/2; if (numberOfContours > nMaxContours) return 0; for (i=0; i<numberOfContours; i++) |