Skip to content

Commit 1cb9b1c

Browse files
Fix signature of libc memory usage function on Linux
A soundness issue!
1 parent ea27351 commit 1cb9b1c

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

crates/profile/src/memory_usage.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@ fn memusage_linux() -> MemoryUsage {
7878
let alloc = unsafe { libc::mallinfo() }.uordblks as isize;
7979
MemoryUsage { allocated: Bytes(alloc) }
8080
} else {
81-
let mallinfo2: fn() -> libc::mallinfo2 = unsafe { std::mem::transmute(mallinfo2) };
81+
let mallinfo2: extern "C" fn() -> libc::mallinfo2 =
82+
unsafe { std::mem::transmute(mallinfo2) };
8283
let alloc = mallinfo2().uordblks as isize;
8384
MemoryUsage { allocated: Bytes(alloc) }
8485
}

0 commit comments

Comments
 (0)