mirror of https://github.com/boa-dev/boa.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
695 B
30 lines
695 B
2 years ago
|
#![no_main]
|
||
|
|
||
|
mod common;
|
||
|
|
||
|
use crate::common::FuzzSource;
|
||
1 year ago
|
use boa_engine::{Context, Script};
|
||
|
use boa_parser::Source;
|
||
2 years ago
|
use libfuzzer_sys::{fuzz_target, Corpus};
|
||
|
use std::io::Cursor;
|
||
|
|
||
|
fn do_fuzz(original: FuzzSource) -> Corpus {
|
||
|
let mut ctx = Context::builder()
|
||
|
.interner(original.interner)
|
||
|
.instructions_remaining(0)
|
||
1 year ago
|
.build()
|
||
|
.unwrap();
|
||
|
if let Ok(parsed) = Script::parse(
|
||
|
Source::from_reader(Cursor::new(&original.source), None),
|
||
|
None,
|
||
|
&mut ctx,
|
||
|
) {
|
||
|
let _ = parsed.codeblock(&mut ctx);
|
||
2 years ago
|
Corpus::Keep
|
||
|
} else {
|
||
|
Corpus::Reject
|
||
|
}
|
||
|
}
|
||
|
|
||
|
fuzz_target!(|original: FuzzSource| -> Corpus { do_fuzz(original) });
|