Fix array bounds crash

This commit is contained in:
Nick Lockwood
2020-10-26 08:03:25 +00:00
parent 31a0c63abe
commit 520a4872da
2 changed files with 1052 additions and 1 deletions
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -1288,7 +1288,7 @@ extension Formatter {
endOfDeclaration = linebreakSearchIndex + 1
}
let declarationRange = startOfDeclaration ... (endOfDeclaration ?? parser.tokens.count - 1)
let declarationRange = startOfDeclaration ... min(endOfDeclaration ?? .max, parser.tokens.count - 1)
let declaration = Array(parser.tokens[declarationRange])
parser.removeTokens(in: declarationRange)