Closed
Description
Source:
use std::ffi::CString;
use libc::c_char;
extern "C" {
fn foo(data: *const c_char);
}
pub fn bar(v: &[u8]) {
let cstr = CString::new(v);
unsafe {
foo(cstr.unwrap().as_ptr())
}
}
clippy doesn't complain about this, even though it's equally dangerous to foo(CString::new(v).unwrap().as_ptr())
. It should complain about this formulation as well.
Tested with clippy on play.rust-lang.org: 0.0.212 (2019-08-11 72da101)