mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
cgen: add fixed array bounds checking for non-literal index (#8832)
This commit is contained in:
@ -274,3 +274,14 @@ pub fn is_atty(fd int) int {
|
||||
return C.isatty(fd)
|
||||
}
|
||||
}
|
||||
|
||||
[inline]
|
||||
fn v_fixed_index(i int, len int) int {
|
||||
$if !no_bounds_checking ? {
|
||||
if i < 0 || i >= len {
|
||||
s := 'fixed array index out of range (index: $i, len: $len)'
|
||||
panic(s)
|
||||
}
|
||||
}
|
||||
return i
|
||||
}
|
||||
|
Reference in New Issue
Block a user