Skip to content

Commit

Permalink
fix(dict): detect trie data corruption
Browse files Browse the repository at this point in the history
  • Loading branch information
kanru committed Mar 20, 2024
1 parent 1e59be0 commit 4e26b48
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/dictionary/trie.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ impl TrieNodeView<'_> {
u32::from_le_bytes(self.0[..4].try_into().unwrap()) as usize * Self::SIZE
}
fn child_end(&self) -> usize {
(u32::from_le_bytes(self.0[..4].try_into().unwrap())
+ u16::from_le_bytes(self.0[4..6].try_into().unwrap()) as u32) as usize
(u32::from_le_bytes(self.0[..4].try_into().unwrap()) as usize)
.saturating_add(u16::from_le_bytes(self.0[4..6].try_into().unwrap()) as usize)
* Self::SIZE
}
}
Expand All @@ -66,8 +66,8 @@ impl TrieLeafView<'_> {
u32::from_le_bytes(self.0[..4].try_into().unwrap()) as usize
}
fn data_end(&self) -> usize {
(u32::from_le_bytes(self.0[..4].try_into().unwrap())
+ u16::from_le_bytes(self.0[4..6].try_into().unwrap()) as u32) as usize
(u32::from_le_bytes(self.0[..4].try_into().unwrap()) as usize)
.saturating_add(u16::from_le_bytes(self.0[4..6].try_into().unwrap()) as usize)
}
}

Expand Down

0 comments on commit 4e26b48

Please sign in to comment.