Ignore large fuzzer inputs. (#1085)

This commit is contained in:
Jon Meow
2022-02-23 11:25:34 -08:00
committed by GitHub
parent 656e746bcb
commit c01634ac8f
2 changed files with 15 additions and 0 deletions
@@ -16,6 +16,15 @@ namespace Carbon::Testing {
// NOLINTNEXTLINE: Match the documented fuzzer entry point declaration style.
extern "C" int LLVMFuzzerTestOneInput(const unsigned char* data,
std::size_t size) {
// Ignore large inputs.
// TODO: Investigate replacement with an error limit. Content with errors on
// escaped quotes (`\"` repeated) have O(M * N) behavior for M errors in a
// file length N, so either that will need to also be fixed or M will need to
// shrink for large (1MB+) inputs.
// This also affects parse_tree_fuzzer.cpp.
if (size > 100000) {
return 0;
}
auto source = SourceBuffer::CreateFromText(
llvm::StringRef(reinterpret_cast<const char*>(data), size));