fix: to_string_lossy for safer string conversion in __assert_fail

This commit is contained in:
Marsman
2026-02-10 02:29:33 +00:00
parent ab6a2e7322
commit ba90edb97b
+3 -3
View File
@@ -14,9 +14,9 @@ pub unsafe extern "C" fn __assert_fail(
line: c_int,
cond: *const c_char,
) -> ! {
let func = unsafe { CStr::from_ptr(func) }.to_str().unwrap();
let file = unsafe { CStr::from_ptr(file) }.to_str().unwrap();
let cond = unsafe { CStr::from_ptr(cond) }.to_str().unwrap();
let func = unsafe { CStr::from_ptr(func) }.to_string_lossy();
let file = unsafe { CStr::from_ptr(file) }.to_string_lossy();
let cond = unsafe { CStr::from_ptr(cond) }.to_string_lossy();
eprintln!("{}: {}:{}: Assertion `{}` failed.", func, file, line, cond);