summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2022-03-03 09:35:08 +0000
committerMichael Stahl <michael.stahl@allotropia.de>2022-03-04 11:20:50 +0100
commit20b8e046a5e132cb0db2e833ff3e84805511efab (patch)
tree6cb1d631dec06aa010526e974581933bf1b49523 /vcl
parentb709e2aabe0f3981a36d7de92856033fd4cf111c (diff)
ofz: check hmtx offset
Change-Id: I650a37472c70771d40febe52efcb723195856421 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130856 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
Diffstat (limited to 'vcl')
-rw-r--r--vcl/source/fontsubset/sft.cxx25
1 files changed, 21 insertions, 4 deletions
diff --git a/vcl/source/fontsubset/sft.cxx b/vcl/source/fontsubset/sft.cxx
index 9a9163a6787c..ec0272027d6c 100644
--- a/vcl/source/fontsubset/sft.cxx
+++ b/vcl/source/fontsubset/sft.cxx
@@ -2229,12 +2229,29 @@ GlyphData *GetTTRawGlyphData(AbstractTrueTypeFont *ttf, sal_uInt32 glyphID)
}
/* get advance width and left sidebearing */
+ sal_uInt32 nAwOffset;
+ sal_uInt32 nLsboffset;
if (glyphID < ttf->horzMetricCount()) {
- d->aw = GetUInt16(hmtx, 4 * glyphID);
- d->lsb = GetInt16(hmtx, 4 * glyphID + 2);
+ nAwOffset = 4 * glyphID;
+ nLsboffset = 4 * glyphID + 2;
} else {
- d->aw = GetUInt16(hmtx, 4 * (ttf->horzMetricCount() - 1));
- d->lsb = GetInt16(hmtx + ttf->horzMetricCount() * 4, (glyphID - ttf->horzMetricCount()) * 2);
+ nAwOffset = 4 * (ttf->horzMetricCount() - 1);
+ nLsboffset = (ttf->horzMetricCount() * 4) + ((glyphID - ttf->horzMetricCount()) * 2);
+ }
+
+ if (nAwOffset + 2 <= hmtxlength)
+ d->aw = GetUInt16(hmtx, nAwOffset);
+ else
+ {
+ SAL_WARN("vcl.fonts", "hmtx offset " << nAwOffset << " not available");
+ d->aw = 0;
+ }
+ if (nLsboffset + 2 <= hmtxlength)
+ d->lsb = GetInt16(hmtx, nLsboffset);
+ else
+ {
+ SAL_WARN("vcl.fonts", "hmtx offset " << nLsboffset << " not available");
+ d->lsb = 0;
}
return d;