mirror of
https://github.com/RGBCube/serenity
synced 2025-05-24 06:05:08 +00:00
FuzzJs: If the program successfully parsed, try running it
This should help us get a lot more coverage in LibJS.
This commit is contained in:
parent
7bb18215cb
commit
c49899b0b6
1 changed files with 8 additions and 1 deletions
|
@ -25,8 +25,10 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <AK/StringView.h>
|
#include <AK/StringView.h>
|
||||||
|
#include <LibJS/Interpreter.h>
|
||||||
#include <LibJS/Lexer.h>
|
#include <LibJS/Lexer.h>
|
||||||
#include <LibJS/Parser.h>
|
#include <LibJS/Parser.h>
|
||||||
|
#include <LibJS/Runtime/GlobalObject.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
|
@ -35,6 +37,11 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
|
||||||
auto js = AK::StringView(static_cast<const unsigned char*>(data), size);
|
auto js = AK::StringView(static_cast<const unsigned char*>(data), size);
|
||||||
auto lexer = JS::Lexer(js);
|
auto lexer = JS::Lexer(js);
|
||||||
auto parser = JS::Parser(lexer);
|
auto parser = JS::Parser(lexer);
|
||||||
parser.parse_program();
|
auto program = parser.parse_program();
|
||||||
|
if (!parser.has_errors()) {
|
||||||
|
auto vm = JS::VM::create();
|
||||||
|
auto interpreter = JS::Interpreter::create<JS::GlobalObject>(*vm);
|
||||||
|
interpreter->run(interpreter->global_object(), *program);
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue