2020-05-09 09:23:26 -03:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2020, the SerenityOS developers.
|
2022-01-16 09:16:04 -03:00
|
|
|
* Copyright (c) 2022, Luke Wilde <lukew@serenityos.org>
|
2020-05-09 09:23:26 -03:00
|
|
|
*
|
2021-04-22 05:24:48 -03:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-05-09 09:23:26 -03:00
|
|
|
*/
|
|
|
|
|
|
2020-04-08 05:40:02 -03:00
|
|
|
#include <AK/StringView.h>
|
2021-01-03 12:01:36 -03:00
|
|
|
#include <LibJS/Interpreter.h>
|
|
|
|
|
#include <LibJS/Runtime/GlobalObject.h>
|
2022-01-16 09:16:04 -03:00
|
|
|
#include <LibJS/Script.h>
|
2020-04-08 05:40:02 -03:00
|
|
|
#include <stddef.h>
|
|
|
|
|
#include <stdint.h>
|
|
|
|
|
|
2022-04-01 14:58:27 -03:00
|
|
|
extern "C" int LLVMFuzzerTestOneInput(uint8_t const* data, size_t size)
|
2020-04-08 05:40:02 -03:00
|
|
|
{
|
2022-04-01 14:58:27 -03:00
|
|
|
auto js = StringView(static_cast<unsigned char const*>(data), size);
|
2022-01-16 09:16:04 -03:00
|
|
|
auto vm = JS::VM::create();
|
|
|
|
|
auto interpreter = JS::Interpreter::create<JS::GlobalObject>(*vm);
|
|
|
|
|
auto parse_result = JS::Script::parse(js, interpreter->realm());
|
|
|
|
|
if (!parse_result.is_error())
|
|
|
|
|
(void)interpreter->run(parse_result.value());
|
|
|
|
|
|
2020-04-08 05:40:02 -03:00
|
|
|
return 0;
|
|
|
|
|
}
|