Skip to content

Commit 76ca1b6

Browse files
Samuel Huylebroeckitext-teamcity
authored andcommitted
Guard against array out of bounds exception in TextRenderer
TSALES-1454 Autoported commit. Original commit hash: [dbab53746]
1 parent 62676ed commit 76ca1b6

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

itext/itext.layout/itext/layout/renderer/TextRenderer.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,8 @@ public override LayoutResult Layout(LayoutContext layoutContext) {
235235
}
236236
Glyph currentGlyph = text.Get(ind);
237237
if (NoPrint(currentGlyph)) {
238-
if (splitCharacters.IsSplitCharacter(text, ind + 1) && TextUtil.IsSpaceOrWhitespace(text.Get(ind + 1))) {
238+
if (ind + 1 == text.end || splitCharacters.IsSplitCharacter(text, ind + 1) && TextUtil.IsSpaceOrWhitespace
239+
(text.Get(ind + 1))) {
239240
nonBreakablePartEnd = ind;
240241
break;
241242
}
@@ -648,7 +649,7 @@ public override void Draw(DrawContext drawContext) {
648649
if (horizontalScaling != null && horizontalScaling != 1) {
649650
canvas.SetHorizontalScaling((float)horizontalScaling * 100);
650651
}
651-
GlyphLine.IGlyphLineFilter filter = new _IGlyphLineFilter_683();
652+
GlyphLine.IGlyphLineFilter filter = new _IGlyphLineFilter_684();
652653
bool appearanceStreamLayout = true.Equals(GetPropertyAsBoolean(Property.APPEARANCE_STREAM_LAYOUT));
653654
if (GetReversedRanges() != null) {
654655
bool writeReversedChars = !appearanceStreamLayout;
@@ -712,8 +713,8 @@ public override void Draw(DrawContext drawContext) {
712713
}
713714
}
714715

715-
private sealed class _IGlyphLineFilter_683 : GlyphLine.IGlyphLineFilter {
716-
public _IGlyphLineFilter_683() {
716+
private sealed class _IGlyphLineFilter_684 : GlyphLine.IGlyphLineFilter {
717+
public _IGlyphLineFilter_684() {
717718
}
718719

719720
public bool Accept(Glyph glyph) {

port-hash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
6a4ae76813a075b405ac61131bfabd94b2b6c41d
1+
dbab5374686a1d8971a2554aad565ef8bd39e643

0 commit comments

Comments
 (0)