ofz#539034285 check for invalid encoding indexes

Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: Ie5039411e1363fec7ee60be999751ce5d9e71153
Reviewed-on: https://gerrit.collaboraoffice.com/c/online/+/7874
Tested-by: Jenkins CPCI <releng@collaboraoffice.com>
Reviewed-by: Noel Grandin <noel.grandin@collabora.com>
(cherry picked from commit d6ad752c9e89c84e487458d92e7ffa0886a4cd4d)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/208768
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
This commit is contained in:
Caolán McNamara
2026-07-29 13:45:24 +02:00
committed by Xisco Fauli
parent ad9e26606f
commit 4aee95b7fb
+19 -2
View File
@@ -3124,16 +3124,33 @@ OString CffContext::getGlyphName(int nGlyphIndex)
bool CffContext::getBaseAccent(ValType aBase, ValType aAccent, int* nBase, int* nAccent)
{
// the seac-like operands are codes in the standard encoding
const int nBaseCode = static_cast<int>(aBase);
const int nAccentCode = static_cast<int>(aAccent);
const int nEncodingSize = SAL_N_ELEMENTS(pStandardEncoding);
if (nBaseCode < 0 || nBaseCode >= nEncodingSize)
{
SAL_WARN("vcl.fonts.cff",
"base char code " << nBaseCode << " outside the standard encoding");
return false;
}
if (nAccentCode < 0 || nAccentCode >= nEncodingSize)
{
SAL_WARN("vcl.fonts.cff",
"accent char code " << nAccentCode << " outside the standard encoding");
return false;
}
bool bBase = false, bAccent = false;
for (int i = 0; i < mnCharStrCount; i++)
{
OString pGlyphName = getGlyphName(i);
if (pGlyphName == pStandardEncoding[int(aBase)])
if (pGlyphName == pStandardEncoding[nBaseCode])
{
*nBase = i;
bBase = true;
}
if (pGlyphName == pStandardEncoding[int(aAccent)])
if (pGlyphName == pStandardEncoding[nAccentCode])
{
*nAccent = i;
bAccent = true;