| 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 <stddef.h> |
| 6 #include <stdint.h> |
| 5 #include "platform/SharedBuffer.h" | 7 #include "platform/SharedBuffer.h" |
| 6 #include "platform/heap/Handle.h" | 8 #include "platform/heap/Handle.h" |
| 7 #include "platform/mhtml/ArchiveResource.h" | 9 #include "platform/mhtml/ArchiveResource.h" |
| 8 #include "platform/mhtml/MHTMLParser.h" | 10 #include "platform/mhtml/MHTMLParser.h" |
| 9 #include "platform/testing/BlinkFuzzerTestSupport.h" | 11 #include "platform/testing/BlinkFuzzerTestSupport.h" |
| 10 #include <stddef.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 MHTMLParser mhtmlParser(SharedBuffer::create(data, size)); | 17 MHTMLParser mhtmlParser(SharedBuffer::create(data, size)); |
| 18 HeapVector<Member<ArchiveResource>> mhtmlArchives = | 18 HeapVector<Member<ArchiveResource>> mhtmlArchives = |
| 19 mhtmlParser.parseArchive(); | 19 mhtmlParser.parseArchive(); |
| 20 mhtmlArchives.clear(); | 20 mhtmlArchives.clear(); |
| 21 ThreadState::current()->collectAllGarbage(); | 21 ThreadState::current()->collectAllGarbage(); |
| 22 | 22 |
| 23 return 0; | 23 return 0; |
| 24 } | 24 } |
| 25 | 25 |
| 26 } // namespace blink | 26 } // namespace blink |
| 27 | 27 |
| 28 extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { | 28 extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { |
| 29 return blink::LLVMFuzzerTestOneInput(data, size); | 29 return blink::LLVMFuzzerTestOneInput(data, size); |
| 30 } | 30 } |
| 31 | 31 |
| 32 extern "C" int LLVMFuzzerInitialize(int* argc, char*** argv) { | 32 extern "C" int LLVMFuzzerInitialize(int* argc, char*** argv) { |
| 33 blink::InitializeBlinkFuzzTest(argc, argv); | 33 blink::InitializeBlinkFuzzTest(argc, argv); |
| 34 return 0; | 34 return 0; |
| 35 } | 35 } |
| OLD | NEW |