Fix possible infinite loop in delocate.go.

I had a brain-fart and had in mind that strings.Index(x[i:], _) would
return a value relative to the beginning of |x|, which is impossible.

Change-Id: I905ea1fa3469ea13f2e3b782c4baf2431b615a2f
Reviewed-on: https://boringssl-review.googlesource.com/15146
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
This commit is contained in:
Adam Langley 2017-04-17 11:48:08 -07:00 committed by CQ bot account: commit-bot@chromium.org
parent 2c45fa0b90
commit fb83bc32ae

View File

@ -382,7 +382,10 @@ func asLines(lines []string, path string, uniqueId int) ([]string, error) {
for _, line := range contents { for _, line := range contents {
for symbol, mappedSymbol := range localSymbols { for symbol, mappedSymbol := range localSymbols {
for i := strings.Index(line, symbol); i >= 0; i = strings.Index(line[i:], symbol) { i := 0
for match := strings.Index(line, symbol); match >= 0; match = strings.Index(line[i:], symbol) {
i += match
before := ' ' before := ' '
if i > 0 { if i > 0 {
before, _ = utf8.DecodeLastRuneInString(line[:i]) before, _ = utf8.DecodeLastRuneInString(line[:i])