Closed
Description
Hi!
Similarly to the temporary_cstring_as_ptr
lint, a common mistake I've run into when dealing with FFI a bunch is immediately trying to get a raw pointer from an initialized vec:
let ptr = vec![0; 4].as_mut_ptr();
This is a really easy way to get a dangling pointer and can be easily overlooked. It would be great if we had a clippy lint for it and as_ptr
as well.
There are quite a few ways to initialize a vec that should be also taken into consideration, for example:
let ptr = Vec::from_elem(0, 4).as_mut_ptr();