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(); | |
esprehn
2016/08/04 04:37:53
why manually clear on stack vectors?
Łukasz Anforowicz
2016/08/04 17:37:30
So that the garbage collection forced on the next
| |
24 ThreadHeap::collectAllGarbage(); | |
esprehn
2016/08/04 04:37:53
Why do you need to do manual Oilpan GC's?
Łukasz Anforowicz
2016/08/04 17:37:30
Because otherwise libFuzzer will report a memory l
| |
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 static blink::ScopedUnittestsEnvironmentSetup testSetup( | |
41 *argc, *argv, blink::ScopedUnittestsEnvironmentSetup::TestType::LibFuzze r); | |
42 | |
43 return 0; | |
44 } | |
OLD | NEW |