Skip to content

Commit

Permalink
Ensure precondition is met when using slice::from_raw_parts
Browse files Browse the repository at this point in the history
  • Loading branch information
Dekker1 committed Apr 4, 2024
1 parent 178b783 commit 4f77fa3
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion crates/pindakaas/src/solver/libloading.rs
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,11 @@ pub(crate) unsafe extern "C" fn ipasir_check_model_cb(
model: *const i32,
) -> bool {
let prop = &mut *(state as *mut IpasirPropStore);
let sol = std::slice::from_raw_parts(model, len);
let sol = if len > 0 {
std::slice::from_raw_parts(model, len)
} else {
&[]
};
let sol: std::collections::HashMap<Var, bool> = sol
.iter()
.map(|&i| (Var(NonZeroI32::new(i.abs()).unwrap()), i >= 0))
Expand Down

0 comments on commit 4f77fa3

Please sign in to comment.