Skip to content

Commit b86e230

Browse files
committed
Merge branch 'transmute_unchecked' of https://github.com/AlexLB99/verify-rust-std into transmute_unchecked
2 parents 3e596c2 + f813be8 commit b86e230

File tree

3 files changed

+503
-16
lines changed

3 files changed

+503
-16
lines changed

library/core/src/ffi/c_str.rs

+15-2
Original file line numberDiff line numberDiff line change
@@ -885,7 +885,20 @@ mod verify {
885885
assert!(c_str.is_safe());
886886
}
887887
}
888-
888+
889+
#[kani::proof]
890+
#[kani::unwind(17)]
891+
fn check_from_bytes_with_nul() {
892+
const MAX_SIZE: usize = 16;
893+
let string: [u8; MAX_SIZE] = kani::any();
894+
let slice = kani::slice::any_slice_of_array(&string);
895+
896+
let result = CStr::from_bytes_with_nul(slice);
897+
if let Ok(c_str) = result {
898+
assert!(c_str.is_safe());
899+
}
900+
}
901+
889902
// pub const fn count_bytes(&self) -> usize
890903
#[kani::proof]
891904
#[kani::unwind(32)]
@@ -956,4 +969,4 @@ mod verify {
956969
assert_eq!(expected_is_empty, c_str.is_empty());
957970
assert!(c_str.is_safe());
958971
}
959-
}
972+
}

0 commit comments

Comments
 (0)