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