Skip to content

Commit 32080cc

Browse files
fix: get_mach_cpu_type do not mutate imutable variable with raw pointers (#849)
1 parent 194bf64 commit 32080cc

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

src/binary_parser.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,14 @@ impl BinaryInfo {
2929

3030
#[cfg(target_os = "macos")]
3131
fn get_mach_cpu_type() -> goblin::mach::cputype::CpuType {
32-
let is_arm: i32 = 0;
33-
let size: usize = std::mem::size_of_val(&is_arm);
32+
let mut is_arm: i32 = 0;
33+
let mut size: libc::size_t = size_of_val(&is_arm);
3434
unsafe {
3535
let name = std::ffi::CString::new("hw.optional.arm64").expect("CString::new failed");
3636
let ret = libc::sysctlbyname(
3737
name.as_ptr() as *const i8,
38-
&is_arm as *const _ as *mut _,
39-
&size as *const _ as *mut _,
38+
&mut is_arm as *mut _ as *mut libc::c_void,
39+
&mut size,
4040
std::ptr::null_mut(),
4141
0,
4242
);

0 commit comments

Comments
 (0)