add checks to make sure access won't be out of bounds

This commit is contained in:
Saurabh 2022-04-22 12:14:18 -06:00
parent 19c7f19afa
commit f77e12ff2f

View File

@ -30,6 +30,8 @@ pub fn spmm_cs_prealloc_unchecked<T>(
where where
T: Scalar + ClosedAdd + ClosedMul + Zero + One, T: Scalar + ClosedAdd + ClosedMul + Zero + One,
{ {
assert_eq!(c.pattern().major_dim(), a.pattern().major_dim());
assert_eq!(c.pattern().minor_dim(), b.pattern().minor_dim());
let some_val = Zero::zero(); let some_val = Zero::zero();
let mut scratchpad_values: Vec<T> = vec![some_val; b.pattern().minor_dim()]; let mut scratchpad_values: Vec<T> = vec![some_val; b.pattern().minor_dim()];
for i in 0..c.pattern().major_dim() { for i in 0..c.pattern().major_dim() {