OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "platform/SharedBuffer.h" |
| 6 #include "platform/heap/Handle.h" |
| 7 #include "platform/mhtml/ArchiveResource.h" |
| 8 #include "platform/mhtml/MHTMLParser.h" |
| 9 #include "platform/testing/TestingPlatformSupport.h" |
| 10 #include "wtf/Assertions.h" |
| 11 #include "wtf/Compiler.h" |
| 12 #include <memory> |
| 13 #include <stddef.h> |
| 14 #include <stdint.h> |
| 15 |
| 16 namespace blink { |
| 17 |
| 18 // Fuzzer for blink::MHTMLParser. |
| 19 int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) |
| 20 { |
| 21 MHTMLParser mhtmlParser(SharedBuffer::create(data, size)); |
| 22 HeapVector<Member<ArchiveResource>> mhtmlArchives = mhtmlParser.parseArchive
(); |
| 23 mhtmlArchives.clear(); |
| 24 ThreadHeap::collectAllGarbage(); |
| 25 |
| 26 return 0; |
| 27 } |
| 28 |
| 29 } // namespace blink |
| 30 |
| 31 extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) |
| 32 { |
| 33 return blink::LLVMFuzzerTestOneInput(data, size); |
| 34 } |
| 35 |
| 36 extern "C" int LLVMFuzzerInitialize(int *argc, char ***argv) |
| 37 { |
| 38 // Intentional leak - no need to do cleanup as explained in |
| 39 // "Initialization/Cleanup" section of testing/libfuzzer/efficient_fuzzer.md |
| 40 DEFINE_STATIC_LOCAL(blink::ScopedUnittestsEnvironmentSetup, testSetup, (*arg
c, *argv)); |
| 41 ALLOW_UNUSED_LOCAL(testSetup); |
| 42 |
| 43 return 0; |
| 44 } |
OLD | NEW |