Skip to content

Commit

Permalink
fix small string
Browse files Browse the repository at this point in the history
  • Loading branch information
sno2 committed Jul 24, 2023
1 parent 3cc32c0 commit d1051f6
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions nova_vm/src/small_string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ impl SmallString {
}

pub(crate) fn from_str_unchecked(value: &str) -> Self {
assert!(value.len() < 8);
debug_assert!(value.len() < 8 && !value.as_bytes().contains(&0));
let mut data: [u8; 7] = [0, 0, 0, 0, 0, 0, 0];
data.copy_from_slice(value.as_bytes());
Self { data }
Expand All @@ -34,7 +34,7 @@ impl SmallString {
impl TryFrom<&str> for SmallString {
type Error = ();
fn try_from(value: &str) -> Result<Self, Self::Error> {
if value.len() < 8 {
if value.len() < 8 && !value.as_bytes().contains(&0) {
Ok(Self::from_str_unchecked(value))
} else {
Err(())
Expand Down

0 comments on commit d1051f6

Please sign in to comment.