Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(82)

Side by Side Diff: testing/libfuzzer/fuzzers/template_url_parser_fuzzer.cc

Issue 2820133004: Only initialize ICU once in the template URL parser fuzzer. (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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> 5 #include <stddef.h>
6 #include <stdint.h> 6 #include <stdint.h>
7 7
8 #include <random> 8 #include <random>
9 #include <string> 9 #include <string>
10 10
(...skipping 14 matching lines...) Expand all
25 25
26 private: 26 private:
27 std::mt19937 generator_; 27 std::mt19937 generator_;
28 std::uniform_int_distribution<uint8_t> pool_; 28 std::uniform_int_distribution<uint8_t> pool_;
29 }; 29 };
30 30
31 struct FuzzerFixedParams { 31 struct FuzzerFixedParams {
32 uint32_t seed_; 32 uint32_t seed_;
33 }; 33 };
34 34
35 base::AtExitManager at_exit_manager; // used by ICU integration
36
37 extern "C" int LLVMFuzzerInitialize(int argc, char*** argv) {
38 CHECK(base::i18n::InitializeICU());
39 return 0;
40 }
41
35 extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { 42 extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
36 if (size < sizeof(FuzzerFixedParams)) { 43 if (size < sizeof(FuzzerFixedParams)) {
37 return 0; 44 return 0;
38 } 45 }
39 base::AtExitManager at_exit_manager; // used by ICU integration.
40 base::i18n::InitializeICU();
41 const FuzzerFixedParams* params = 46 const FuzzerFixedParams* params =
42 reinterpret_cast<const FuzzerFixedParams*>(data); 47 reinterpret_cast<const FuzzerFixedParams*>(data);
43 size -= sizeof(FuzzerFixedParams); 48 size -= sizeof(FuzzerFixedParams);
44 const char* char_data = reinterpret_cast<const char*>(params + 1); 49 const char* char_data = reinterpret_cast<const char*>(params + 1);
45 PseudoRandomFilter filter(params->seed_); 50 PseudoRandomFilter filter(params->seed_);
46 TemplateURLParser::Parse(SearchTermsData(), char_data, size, &filter); 51 TemplateURLParser::Parse(SearchTermsData(), char_data, size, &filter);
47 return 0; 52 return 0;
48 } 53 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698