difftreelog
fix unchecked conversion of array index
in: master
2 files changed
crates/jrsonnet-evaluator/src/error.rsdiffbeforeafterboth114 InComprehensionCanOnlyIterateOverArray,114 InComprehensionCanOnlyIterateOverArray,115115116 #[error("array out of bounds: {0} is not within [0,{1})")]116 #[error("array out of bounds: {0} is not within [0,{1})")]117 ArrayBoundsError(usize, usize),117 ArrayBoundsError(isize, usize),118 #[error("string out of bounds: {0} is not within [0,{1})")]118 #[error("string out of bounds: {0} is not within [0,{1})")]119 StringBoundsError(usize, usize),119 StringBoundsError(usize, usize),120120crates/jrsonnet-evaluator/src/evaluate/mod.rsdiffbeforeafterboth18 function::{CallLocation, FuncDesc, FuncVal},18 function::{CallLocation, FuncDesc, FuncVal},19 typed::Typed,19 typed::Typed,20 val::{CachedUnbound, IndexableVal, StrValue, Thunk, ThunkValue},20 val::{CachedUnbound, IndexableVal, StrValue, Thunk, ThunkValue},21 Context, GcHashMap, ObjValue, ObjValueBuilder, ObjectAssertion, Pending, Result, ResultExt,21 Context, Error, GcHashMap, ObjValue, ObjValueBuilder, ObjectAssertion, Pending, Result,22 State, Unbound, Val, Error,22 ResultExt, State, Unbound, Val,23};23};24pub mod destructure;24pub mod destructure;25pub mod operator;25pub mod operator;518 if n.fract() > f64::EPSILON {518 if n.fract() > f64::EPSILON {519 bail!(FractionalIndex)519 bail!(FractionalIndex)520 }520 }521 if n < 0.0 {522 bail!(ArrayBoundsError(n as isize, v.len()));523 }521 v.get(n as usize)?524 v.get(n as usize)?522 .ok_or_else(|| ArrayBoundsError(n as usize, v.len()))?525 .ok_or_else(|| ArrayBoundsError(n as isize, v.len()))?523 }526 }524 (Val::Arr(_), Val::Str(n)) => {527 (Val::Arr(_), Val::Str(n)) => {525 bail!(AttemptedIndexAnArrayWithString(n.into_flat()))528 bail!(AttemptedIndexAnArrayWithString(n.into_flat()))