We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 01ccaa2 commit a89c325Copy full SHA for a89c325
cpufeatures/src/aarch64.rs
@@ -121,13 +121,18 @@ macro_rules! check {
121
/// macOS helper function for calling `sysctlbyname`.
122
#[cfg(target_os = "macos")]
123
pub unsafe fn sysctlbyname(name: &[u8]) -> bool {
124
- let name = core::ffi::CStr::from_bytes_with_nul(name).unwrap();
+ assert_eq!(
125
+ name.last().cloned(),
126
+ Some(0),
127
+ "name is not NUL terminated: {:?}",
128
+ name
129
+ );
130
131
let mut value: u32 = 0;
132
let mut size = core::mem::size_of::<u32>();
133
134
let rc = libc::sysctlbyname(
- name.as_ptr(),
135
+ name.as_ptr() as *const i8,
136
&mut value as *mut _ as *mut libc::c_void,
137
&mut size,
138
core::ptr::null_mut(),
0 commit comments