Stop using fuzz input for filenames (#1078)

This commit is contained in:
Jon Meow
2022-02-16 10:10:58 -08:00
committed by GitHub
parent 74c054c86e
commit 50f5b3f226
2 changed files with 2 additions and 44 deletions
+1 -21
View File
@@ -18,28 +18,8 @@ namespace Carbon::Testing {
// NOLINTNEXTLINE: Match the documented fuzzer entry point declaration style.
extern "C" int LLVMFuzzerTestOneInput(const unsigned char* data,
std::size_t size) {
// We need two bytes of data to compute a file name length.
if (size < 2) {
return 0;
}
uint16_t raw_filename_length;
std::memcpy(&raw_filename_length, data, 2);
data += 2;
size -= 2;
std::size_t filename_length = raw_filename_length;
// We need enough data to populate this filename length.
if (size < filename_length) {
return 0;
}
llvm::StringRef filename(reinterpret_cast<const char*>(data),
filename_length);
data += filename_length;
size -= filename_length;
// The rest of the data is the source text.
auto source = SourceBuffer::CreateFromText(
llvm::StringRef(reinterpret_cast<const char*>(data), size), filename);
llvm::StringRef(reinterpret_cast<const char*>(data), size));
// Lex the input.
auto tokens = TokenizedBuffer::Lex(source, NullDiagnosticConsumer());