Skip to content

Commit cda5ec9

Browse files
committed
utf16 string reading, shouldnt crash, if there is error return empty string
1 parent 580c6df commit cda5ec9

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

crates/libmwemu/src/maps/mem64.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,11 @@ impl Mem64 {
533533
}
534534
}).unwrap();
535535
}
536-
String::from_utf16(&s).expect("invalid utf-16")
536+
537+
match String::from_utf16(&s) {
538+
Ok(s) => { return s; }
539+
Err(_) => { return "".to_string(); }
540+
}
537541
}
538542

539543
pub fn read_wide_string_n(&self, addr: u64, max_chars: usize) -> String {

0 commit comments

Comments
 (0)