1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 07:47:37 +00:00

LibPDF/CFF: Fix off-by-one when reading internal encoding

We use `i - 1` to index these arrays, so that's what we should use
for the bounds check as well.
This commit is contained in:
Nico Weber 2024-02-19 21:43:58 -05:00 committed by Sam Atkins
parent abaca60f9a
commit 4705d38fa7

View file

@ -279,8 +279,9 @@ PDFErrorOr<NonnullRefPtr<CFF>> CFF::create(ReadonlyBytes const& cff_bytes, RefPt
encoding->set(0, ".notdef");
continue;
}
if (i >= encoding_codes.size() || i >= charset_names.size())
if (i - 1 >= encoding_codes.size() || i - 1 >= charset_names.size()) {
break;
}
auto code = encoding_codes[i - 1];
auto char_name = charset_names[i - 1];
encoding->set(code, char_name);