Skip to content

Commit

Permalink
Tries to fix the fuzzer build
Browse files Browse the repository at this point in the history
Building the fuzzers did not work for me.

It looks like the commit `8426914` broke the `fuzz/fuzz-configuration-json.cpp`
and the commit `fe5742f` broke the `fuzz/fuzz-parse-ling.cpp`
  • Loading branch information
rol1510 authored Jan 11, 2024
1 parent 9b3b638 commit 4c2d145
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
5 changes: 4 additions & 1 deletion fuzz/fuzz-configuration-json.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <cstdint>
#include <quick-lint-js/configuration/configuration.h>
#include <quick-lint-js/container/padded-string.h>
#include <quick-lint-js/diag/diag-list.h>
#include <quick-lint-js/diag/diag-reporter.h>
#include <quick-lint-js/port/char8.h>

Expand All @@ -14,7 +15,9 @@ int LLVMFuzzerTestOneInput(const std::uint8_t *data, std::size_t size) {

Padded_String json(String8(reinterpret_cast<const Char8 *>(data), size));
Configuration c;
c.load_from_json(&json, &Null_Diag_Reporter::instance);
Monotonic_Allocator temp_memory("fuzz");
Diag_List diags(&temp_memory);
c.load_from_json(&json, &diags);

return 0;
}
Expand Down
8 changes: 6 additions & 2 deletions fuzz/fuzz-parse-lint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include <cstddef>
#include <cstdint>
#include <quick-lint-js/configuration/configuration.h>
#include <quick-lint-js/container/padded-string.h>
#include <quick-lint-js/diag/diag-reporter.h>
#include <quick-lint-js/fe/global-declared-variable-set.h>
Expand All @@ -13,10 +14,13 @@ extern "C" {
int LLVMFuzzerTestOneInput(const std::uint8_t *data, std::size_t size) {
quick_lint_js::Padded_String source(quick_lint_js::String8(
reinterpret_cast<const quick_lint_js::Char8 *>(data), size));
quick_lint_js::Global_Declared_Variable_Set globals;

quick_lint_js::Configuration config;
quick_lint_js::parse_and_lint(&source,
quick_lint_js::Null_Diag_Reporter::instance,
globals, quick_lint_js::Linter_Options());
quick_lint_js::Linter_Options{
.configuration = &config,
});
return 0;
}
}
Expand Down

0 comments on commit 4c2d145

Please sign in to comment.