Check for index out of range in GlyphDataTable.ReadFlags() and fix #1199

This commit is contained in:
BobLd
2025-11-07 19:03:08 +00:00
parent 181fa9d837
commit b49e5aa697
3 changed files with 24 additions and 1 deletions

View File

@@ -338,7 +338,15 @@
for (int j = 0; j < numberOfRepeats; j++)
{
result[i + j + 1] = result[i];
int p = i + j + 1;
if (p >= result.Length)
{
// Unsure why this happens but fixes #1199
// TODO - Is there a better fix?
break;
}
result[p] = result[i];
}
i += numberOfRepeats;

View File

@@ -8,6 +8,21 @@
public class GithubIssuesTests
{
[Fact]
public void Issue1199()
{
var path = IntegrationHelpers.GetDocumentPath("TrueTypeTablesGlyphDataTableReadGlyphsError.pdf");
using (var document = PdfDocument.Open(path, new ParsingOptions() { UseLenientParsing = true }))
{
for (int p = 1; p <= document.NumberOfPages; p++)
{
var page = document.GetPage(p);
Assert.NotNull(page);
}
}
}
[Fact]
public void Issue1183()
{