bakkesmod-rust
bakkesmod-rust copied to clipboard
Possible public unsafe API
pub struct RLArray<T: UnrealPointer> {
pub data: *mut usize,
count: u32,
max: u32,
phantom: PhantomData<T>
}
pub fn get(&self, index: isize) -> T {
unsafe {
let ptr = self.data.offset(index);
T::from_ptr(*ptr)
}
}
Hi there, publicly possible RLArray::get calculate the pointer using the parameter index and public field data without sufficient checks, which might cause memory issues. In Rust, we should not cause any memory issues by merely using safe functions.
Suggestions:
- make the field private
- add sufficient check
- mark this function unsafe