8000 Prevent index out of bounds exception. · icssjs/TypeScript@2eb1a21 · GitHub
[go: up one dir, main page]

Skip to content

Commit 2eb1a21

Browse files
Prevent index out of bounds exception.
1 parent 17dd6c2 commit 2eb1a21

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/compiler/parser.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -850,7 +850,7 @@ module ts {
850850
// Much of the time the parser will need the very next node in the array that
851851
// we just returned a node from.So just simply check for that case and move
852852
// forward in the array instead of searching for the node again.
853-
if (current && current.end === position && currentArrayIndex < currentArray.length) {
853+
if (current && current.end === position && currentArrayIndex < (currentArray.length - 1)) {
854854
currentArrayIndex++;
855855
current = currentArray[currentArrayIndex];
856856
}
@@ -886,6 +886,7 @@ module ts {
886886

887887
// Recurse into the source file to find the highest node at this position.
888888
forEachChild(sourceFile, visitNode, visitArray);
889+
return;
889890

890891
function visitNode(node: Node) {
891892
if (position >= node.pos && position < node.end) {

0 commit comments

Comments
 (0)
0