1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 11:37:44 +00:00

uucore: set the unsafe at the right place

This commit is contained in:
Sylvestre Ledru 2025-03-08 15:24:55 +01:00
parent a85539f530
commit d671849b7f

View file

@ -164,11 +164,11 @@ pub struct Passwd {
/// ptr must point to a valid C string. /// ptr must point to a valid C string.
/// ///
/// Returns None if ptr is null. /// Returns None if ptr is null.
unsafe fn cstr2string(ptr: *const c_char) -> Option<String> { fn cstr2string(ptr: *const c_char) -> Option<String> {
if ptr.is_null() { if ptr.is_null() {
None None
} else { } else {
Some(CStr::from_ptr(ptr).to_string_lossy().into_owned()) Some(unsafe { CStr::from_ptr(ptr).to_string_lossy().into_owned() })
} }
} }