Skip to content

Commit 65bc7e2

Browse files
fix: Ensure array accessor for width array is in bounds
1 parent a33093c commit 65bc7e2

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/iTextSharp.LGPLv2.Core/iTextSharp/text/pdf/PdfPTable.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1363,15 +1363,16 @@ internal float[][] GetEventWidths(float xPos, int firstRow, int lastRow, bool in
13631363
lastRow = Math.Max(lastRow, headerRows);
13641364
}
13651365

1366-
var widths = new float[(includeHeaders ? headerRows : 0) + lastRow - firstRow][];
1366+
var numWidths = (includeHeaders ? headerRows : 0) + lastRow - firstRow;
1367+
var widths = new float[numWidths][];
13671368

13681369
if (IsColspan)
13691370
{
13701371
var n = 0;
13711372

13721373
if (includeHeaders)
13731374
{
1374-
for (var k = 0; k < headerRows; ++k)
1375+
for (var k = 0; k < headerRows && n < numWidths; ++k)
13751376
{
13761377
var row = rows[k];
13771378

@@ -1386,7 +1387,7 @@ internal float[][] GetEventWidths(float xPos, int firstRow, int lastRow, bool in
13861387
}
13871388
}
13881389

1389-
for (; firstRow < lastRow; ++firstRow)
1390+
for (; firstRow < lastRow && n < numWidths; ++firstRow)
13901391
{
13911392
var row = rows[firstRow];
13921393

0 commit comments

Comments
 (0)