From ba90edb97b09ae5ba33fac9c3f7adcf360c127cc Mon Sep 17 00:00:00 2001 From: Marsman Date: Tue, 10 Feb 2026 02:29:33 +0000 Subject: [PATCH] fix: `to_string_lossy` for safer string conversion in `__assert_fail` --- src/header/assert/mod.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/header/assert/mod.rs b/src/header/assert/mod.rs index fd4790cf87..208d9019ae 100644 --- a/src/header/assert/mod.rs +++ b/src/header/assert/mod.rs @@ -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);