Bug fix in f_string

This commit is contained in:
xavo95 2025-04-20 20:24:19 +07:00
parent efe6f6173b
commit ac8ba74a3e
Signed by: xavo95
GPG key ID: CBF8ADED6DEBB783

View file

@ -38,12 +38,12 @@ impl Printf<str> for FString {
#[inline(always)]
fn printf_unsafe<A: AsRef<str>>(&mut self, fmt: A) {
let tmp = U16CString::from_str(fmt).unwrap();
let new_len = tmp.len();
let mut tmp_bytes = tmp.into_vec_with_nul();
let new_len = tmp_bytes.len();
if new_len > self.0.cap as usize {
// TODO: use Result instead
panic!("New string is too long and no printf ffi binding has been provided");
}
let mut tmp_bytes = tmp.into_vec_with_nul();
tmp_bytes.resize(self.0.cap as usize, 0);
unsafe {
std::ptr::copy_nonoverlapping(