Hi, I am scanning the embree-rs in the latest version with my own static analyzer tool.
Unsafe conversion found at: src/lib.rs#L88
unsafe {
let mem = alloc::alloc(layout);
assert_eq!((mem as usize) % 16, 0);
Vec::<T>::from_raw_parts(mem as *mut T, len, len)
}
This unsound implementation of Vec::from_raw_parts would create a dangling pointer issues if the mem is dropped automatically or is empty. The 'mem::forget' function can be used to avoid the issue.
This would potentially cause undefined behaviors in Rust. If we further manipulate the problematic converted types, it would potentially lead to different consequences such as uaf or double free. I am reporting this issue for your attention.
Hi, I am scanning the embree-rs in the latest version with my own static analyzer tool.
Unsafe conversion found at: src/lib.rs#L88
This unsound implementation of
Vec::from_raw_parts
would create a dangling pointer issues if themem
is dropped automatically or is empty. The 'mem::forget' function can be used to avoid the issue.This would potentially cause undefined behaviors in Rust. If we further manipulate the problematic converted types, it would potentially lead to different consequences such as uaf or double free. I am reporting this issue for your attention.