Skip to content

Commit

Permalink
fix: skip number
Browse files Browse the repository at this point in the history
  • Loading branch information
liuq19 committed Nov 8, 2024
1 parent f5ede7a commit 25f4f87
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 16 deletions.
13 changes: 0 additions & 13 deletions fuzz/.cargo/config

This file was deleted.

2 changes: 1 addition & 1 deletion scripts/fuzz.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ set -ex

cargo install cargo-fuzz

RUST_BACKTRACE=full cargo +nightly fuzz run fuzz_value -- -max_total_time=20m
RUST_BACKTRACE=full cargo +nightly fuzz run fuzz_value
10 changes: 8 additions & 2 deletions src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1262,7 +1262,8 @@ where
}

// SIMD path for long number
while let Some(chunk) = self.read.peek_n(32) {
const LANES: usize = i8x32::LANES;
while let Some(chunk) = self.read.peek_n(LANES) {
let v = unsafe { i8x32::from_slice_unaligned_unchecked(chunk) };
let zero = i8x32::splat(b'0' as i8);
let nine = i8x32::splat(b'9' as i8);
Expand All @@ -1275,8 +1276,13 @@ where
// check the first digit after the dot
self.skip_single_digit()?;

// check the remaining digits
// check the overflow
cnt += 2;
if cnt >= LANES {
is_float = true;
continue;
}

nondigits = nondigits.wrapping_shr(cnt as u32);
if nondigits != 0 {
let offset = nondigits.trailing_zeros() as usize;
Expand Down
1 change: 1 addition & 0 deletions src/value/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2073,6 +2073,7 @@ mod test {
use crate::Deserializer;

let nums = [
"-46333333333333333333333333333333.6",
"43.420273000",
"1e123",
"0.001","0e+12","0.1e+12",
Expand Down

0 comments on commit 25f4f87

Please sign in to comment.