diff options
author | Caolán McNamara <caolanm@redhat.com> | 2019-07-22 09:24:01 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2019-07-22 17:52:23 +0200 |
commit | 803a6ccb774ff6dc67ca697459d6679e4bc9604f (patch) | |
tree | 49c4e2fac9e6bd1589dee15b7b86506d43a56744 /vcl | |
parent | f6d3e145d7642aae0e6dac292d910149be296e08 (diff) |
cid#1222237 try silence Untrusted value as argument
Change-Id: I9a8303cd996c91855fc624b875fbc8f1286a58b5
Reviewed-on: https://gerrit.libreoffice.org/76100
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/source/fontsubset/sft.cxx | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/vcl/source/fontsubset/sft.cxx b/vcl/source/fontsubset/sft.cxx index 74fa748d0ebf..2e974a10d3c6 100644 --- a/vcl/source/fontsubset/sft.cxx +++ b/vcl/source/fontsubset/sft.cxx @@ -272,8 +272,13 @@ static sal_uInt32 getTableSize(TrueTypeFont const *ttf, sal_uInt32 ord) return ttf->tlens[ord]; } -/* Hex Formatter functions */ -static const char HexChars[] = "0123456789ABCDEF"; +static char toHex(sal_uInt8 nIndex) +{ + /* Hex Formatter functions */ + static const char HexChars[] = "0123456789ABCDEF"; + assert(nIndex < SAL_N_ELEMENTS(HexChars)); + return HexChars[nIndex]; +} static HexFmt *HexFmtNew(FILE *outf) { @@ -324,8 +329,8 @@ static void HexFmtBlockWrite(HexFmt *_this, const void *ptr, sal_uInt32 size) } for (i=0; i<size; i++) { Ch = static_cast<sal_uInt8 const *>(ptr)[i]; - _this->buffer[_this->bufpos++] = HexChars[Ch >> 4]; - _this->buffer[_this->bufpos++] = HexChars[Ch & 0xF]; + _this->buffer[_this->bufpos++] = toHex(Ch >> 4); + _this->buffer[_this->bufpos++] = toHex(Ch & 0xF); if (_this->bufpos == HFORMAT_LINELEN) { HexFmtFlush(_this); fputc('\n', _this->o); |