Fix crash in MakeString.EndsWith()

Bug: 226974242
Test: go test
Change-Id: I21ff26d00ed7be145ae2c1175f1438b6e7d60834
This commit is contained in:
Cole Faust
2022-04-27 13:37:32 -07:00
parent a59059f3a1
commit 35b994e1e7
2 changed files with 31 additions and 1 deletions

View File

@@ -279,7 +279,7 @@ func (ms *MakeString) TrimRightOne() {
func (ms *MakeString) EndsWith(ch rune) bool {
s := ms.Strings[len(ms.Strings)-1]
return s[len(s)-1] == uint8(ch)
return len(s) > 0 && s[len(s)-1] == uint8(ch)
}
func (ms *MakeString) ReplaceLiteral(input string, output string) {