Skip to content

Commit d08cf94

Browse files
committed
Get fuzz targets building again
1 parent f8ba57b commit d08cf94

5 files changed

Lines changed: 8 additions & 21 deletions

File tree

fuzz/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ cargo-fuzz = true
99

1010
[dependencies]
1111
wast = { path = ".." }
12+
wast-parser = { path = "../crates/parser" }
1213
libfuzzer-sys = { git = "https://github.com/rust-fuzz/libfuzzer-sys" }
1314

1415
[[bin]]

fuzz/fuzz_targets/binary.rs

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,8 @@ use libfuzzer_sys::*;
44
use std::str;
55

66
fuzz_target!(|data: &[u8]| {
7-
let s = match str::from_utf8(data) {
8-
Ok(s) => s,
9-
Err(_) => return,
10-
};
11-
let buf = match wast::parser::ParseBuffer::new(s) {
12-
Ok(b) => b,
13-
Err(_) => return,
14-
};
15-
let mut wat = match wast::parser::parse::<wast::ast::Wat>(&buf) {
16-
Ok(m) => m,
17-
Err(_) => return,
18-
};
19-
20-
match wast::resolve::resolve(&mut wat.module) {
21-
Ok(()) => (),
22-
Err(_) => return,
7+
match str::from_utf8(data) {
8+
Ok(s) => drop(wast::parse_str(s)),
9+
Err(_) => {}
2310
}
24-
wast::binary::encode(&wat.module);
2511
});

fuzz/fuzz_targets/lexer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ fuzz_target!(|data: &[u8]| {
88
Ok(s) => s,
99
Err(_) => return,
1010
};
11-
let mut l = wast::lexer::Lexer::new(s);
11+
let mut l = wast_parser::lexer::Lexer::new(s);
1212
while let Ok(Some(_)) = l.parse() {
1313
// ...
1414
}

fuzz/fuzz_targets/parser.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ fuzz_target!(|data: &[u8]| {
88
Ok(s) => s,
99
Err(_) => return,
1010
};
11-
let buf = match wast::parser::ParseBuffer::new(s) {
11+
let buf = match wast_parser::parser::ParseBuffer::new(s) {
1212
Ok(b) => b,
1313
Err(_) => return,
1414
};
15-
drop(wast::parser::parse::<wast::ast::Wast>(&buf));
15+
drop(wast_parser::parser::parse::<wast_parser::ast::Wast>(&buf));
1616
});

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
#![deny(missing_docs)]
6969

7070
use std::fmt;
71-
use std::path::{Path, PathBuf};
71+
use std::path::Path;
7272
use wast_parser::ast;
7373
use wast_parser::binary;
7474
use wast_parser::parser::{self, ParseBuffer};

0 commit comments

Comments
 (0)