Fix possible array-out-of-bounds access, add test.

This commit is contained in:
David Anson 2015-07-22 23:17:08 -07:00
parent 7f5dd9ab6b
commit a958a33860
2 changed files with 25 additions and 1 deletions

View file

@ -65,7 +65,7 @@ function lintContent(content, config) {
token.line = lines[token.map[0]];
token.lineNumber = token.map[0] + 1;
// Trim bottom of token to exclude whitespace lines
while (!(lines[token.map[1] - 1].trim())) {
while (token.map[1] && !(lines[token.map[1] - 1].trim())) {
token.map[1]--;
}
// Annotate children with lineNumber