| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "platform/SharedBuffer.h" | 5 #include "platform/SharedBuffer.h" |
| 6 #include "platform/heap/Handle.h" | 6 #include "platform/heap/Handle.h" |
| 7 #include "platform/mhtml/ArchiveResource.h" | 7 #include "platform/mhtml/ArchiveResource.h" |
| 8 #include "platform/mhtml/MHTMLParser.h" | 8 #include "platform/mhtml/MHTMLParser.h" |
| 9 #include "platform/testing/BlinkFuzzerTestSupport.h" | 9 #include "platform/testing/BlinkFuzzerTestSupport.h" |
| 10 #include <stddef.h> | 10 #include <stddef.h> |
| 11 #include <stdint.h> | 11 #include <stdint.h> |
| 12 | 12 |
| 13 namespace blink { | 13 namespace blink { |
| 14 | 14 |
| 15 // Fuzzer for blink::MHTMLParser. | 15 // Fuzzer for blink::MHTMLParser. |
| 16 int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { | 16 int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { |
| 17 static BlinkFuzzerTestSupport test_support = BlinkFuzzerTestSupport(); |
| 17 MHTMLParser mhtml_parser(SharedBuffer::Create(data, size)); | 18 MHTMLParser mhtml_parser(SharedBuffer::Create(data, size)); |
| 18 HeapVector<Member<ArchiveResource>> mhtml_archives = | 19 HeapVector<Member<ArchiveResource>> mhtml_archives = |
| 19 mhtml_parser.ParseArchive(); | 20 mhtml_parser.ParseArchive(); |
| 20 mhtml_archives.clear(); | 21 mhtml_archives.clear(); |
| 21 ThreadState::Current()->CollectAllGarbage(); | 22 ThreadState::Current()->CollectAllGarbage(); |
| 22 | 23 |
| 23 return 0; | 24 return 0; |
| 24 } | 25 } |
| 25 | 26 |
| 26 } // namespace blink | 27 } // namespace blink |
| 27 | 28 |
| 28 extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { | 29 extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { |
| 29 return blink::LLVMFuzzerTestOneInput(data, size); | 30 return blink::LLVMFuzzerTestOneInput(data, size); |
| 30 } | 31 } |
| 31 | |
| 32 extern "C" int LLVMFuzzerInitialize(int* argc, char*** argv) { | |
| 33 blink::InitializeBlinkFuzzTest(argc, argv); | |
| 34 return 0; | |
| 35 } | |
| OLD | NEW |