Skip to content

Commit

Permalink
Ignore Shift JIS decoding errors in Fst::get_name
Browse files Browse the repository at this point in the history
  • Loading branch information
encounter committed Oct 18, 2024
1 parent be46724 commit d4bca2c
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions nod/src/disc/fst.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,9 @@ impl<'a> Fst<'a> {
let c_string = CStr::from_bytes_until_nul(name_buf).map_err(|_| {
format!("FST: name at offset {} not null-terminated", node.name_offset())
})?;
let (decoded, _, errors) = SHIFT_JIS.decode(c_string.to_bytes());
if errors {
return Err(format!("FST: Failed to decode name at offset {}", node.name_offset()));
}
let (decoded, _, _) = SHIFT_JIS.decode(c_string.to_bytes());
// Ignore decoding errors, we can't do anything about them. Consumers may check for
// U+FFFD (REPLACEMENT CHARACTER), or fetch the raw bytes from the string table.
Ok(decoded)
}

Expand Down

0 comments on commit d4bca2c

Please sign in to comment.