summaryrefslogtreecommitdiff
path: root/Meta
diff options
context:
space:
mode:
authorTimothy Flynn <trflynn89@pm.me>2023-03-17 12:54:27 -0400
committerLinus Groh <mail@linusgroh.de>2023-03-19 00:15:05 +0000
commit1b260ab1f8deac83db52d04a0e8e27ef5a5e44b8 (patch)
treefbb7ce9a077037576cd6a9de1e20979a03deea32 /Meta
parent87bfb47d1f1c0bb8b53a190a8063ce1a22bb4e6f (diff)
downloadserenity-1b260ab1f8deac83db52d04a0e8e27ef5a5e44b8.zip
Meta: Move global VM creation to fuzzer "global" structure
Turns out LLVMFuzzerTestOneInput may be called more than once per process.
Diffstat (limited to 'Meta')
-rw-r--r--Meta/Lagom/Fuzzers/FuzzCSSParser.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/Meta/Lagom/Fuzzers/FuzzCSSParser.cpp b/Meta/Lagom/Fuzzers/FuzzCSSParser.cpp
index cb8d08ad9f..96caf75624 100644
--- a/Meta/Lagom/Fuzzers/FuzzCSSParser.cpp
+++ b/Meta/Lagom/Fuzzers/FuzzCSSParser.cpp
@@ -9,16 +9,21 @@
#include <LibWeb/Platform/EventLoopPluginSerenity.h>
namespace {
+
struct Globals {
Globals();
} globals;
-Globals::Globals() { Web::Platform::EventLoopPlugin::install(*new Web::Platform::EventLoopPluginSerenity); }
-}
-extern "C" int LLVMFuzzerTestOneInput(uint8_t const* data, size_t size)
+Globals::Globals()
{
+ Web::Platform::EventLoopPlugin::install(*new Web::Platform::EventLoopPluginSerenity);
MUST(Web::Bindings::initialize_main_thread_vm());
+}
+}
+
+extern "C" int LLVMFuzzerTestOneInput(uint8_t const* data, size_t size)
+{
// FIXME: There's got to be a better way to do this "correctly"
auto& vm = Web::Bindings::main_thread_vm();
(void)Web::parse_css_stylesheet(Web::CSS::Parser::ParsingContext(*vm.current_realm()), { data, size });