From 57ea1462127520a005fd6487af66cec07a24c6b7 Mon Sep 17 00:00:00 2001 From: Joe Wang Date: Mon, 23 Dec 2013 13:57:42 -0800 Subject: [PATCH] 8029955: AIOB in XMLEntityScanner.scanLiteral upon parsing literals with > 100 LF chars Reviewed-by: dfuchs, lancea, ulfzibis --- .../internal/impl/XMLEntityScanner.java | 43 +++++++++++-------- 1 file changed, 26 insertions(+), 17 deletions(-) diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/XMLEntityScanner.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/XMLEntityScanner.java index 4acc9c94bd5..c27b1560182 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/XMLEntityScanner.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/XMLEntityScanner.java @@ -1142,7 +1142,7 @@ public class XMLEntityScanner implements XMLLocator { int i=0; for ( i = offset; i < fCurrentEntity.position; i++) { fCurrentEntity.ch[i] = '\n'; - whiteSpaceLookup[whiteSpaceLen++]=i; + storeWhiteSpace(i); } int length = fCurrentEntity.position - offset; @@ -1163,27 +1163,18 @@ public class XMLEntityScanner implements XMLLocator { } // scan literal value - while (fCurrentEntity.position < fCurrentEntity.count) { - c = fCurrentEntity.ch[fCurrentEntity.position++]; + for (; fCurrentEntity.position= whiteSpaceLookup.length) { + int [] tmp = new int[whiteSpaceLookup.length + 100]; + System.arraycopy(whiteSpaceLookup, 0, tmp, 0, whiteSpaceLookup.length); + whiteSpaceLookup = tmp; + } + + whiteSpaceLookup[whiteSpaceLen++] = whiteSpacePos; + } + //CHANGED: /** * Scans a range of character data up to the specified delimiter,