mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
array.slice(): bounds out of range check
This commit is contained in:
parent
ac238a5362
commit
4d5336897e
@ -136,8 +136,11 @@ pub fn (s array) slice(start, _end int) array {
|
||||
if start > end {
|
||||
panic('invalid slice index: $start > $end')
|
||||
}
|
||||
if end >= s.len {
|
||||
end = s.len
|
||||
if end > s.len {
|
||||
panic('runtime error: slice bounds out of range ($end >= $s.len)')
|
||||
}
|
||||
if start < 0 {
|
||||
panic('runtime error: slice bounds out of range ($start < 0)')
|
||||
}
|
||||
l := end - start
|
||||
res := array {
|
||||
|
Loading…
Reference in New Issue
Block a user