operator-index.go: ConstLastIndex is checked
This commit is contained in:
parent
d63b18fd76
commit
ff9cf80c66
@ -40,11 +40,14 @@ func verifyRange(indexTerm *term, indexList *ListType, maxValue int) (startIndex
|
||||
v, _ := ((*indexList)[0]).(*intPair)
|
||||
startIndex = v.a
|
||||
endIndex = v.b
|
||||
if endIndex == ConstLastIndex {
|
||||
endIndex = maxValue
|
||||
}
|
||||
if startIndex < 0 && startIndex >= -maxValue {
|
||||
startIndex = maxValue + startIndex
|
||||
}
|
||||
if endIndex < 0 && endIndex >= -maxValue {
|
||||
endIndex = maxValue + endIndex + 1
|
||||
endIndex = maxValue + endIndex
|
||||
}
|
||||
if startIndex < 0 || startIndex > maxValue {
|
||||
err = indexTerm.Errorf("range start-index %d is out of bounds", startIndex)
|
||||
|
Loading…
Reference in New Issue
Block a user