/src/nss/fuzz/targets/lib/base/mutate.cc
Line | Count | Source (jump to first uncovered line) |
1 | | /* This Source Code Form is subject to the terms of the Mozilla Public |
2 | | * License, v. 2.0. If a copy of the MPL was not distributed with this |
3 | | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
4 | | |
5 | | #include "mutate.h" |
6 | | |
7 | | #include <cstddef> |
8 | | #include <cstdint> |
9 | | #include <random> |
10 | | |
11 | | size_t CustomMutate(Mutators mutators, uint8_t* data, size_t size, |
12 | 0 | size_t maxSize, unsigned int seed) { |
13 | 0 | std::mt19937 rng(seed); |
14 | 0 | static std::bernoulli_distribution bdist; |
15 | |
|
16 | 0 | if (bdist(rng)) { |
17 | 0 | std::uniform_int_distribution<size_t> idist(0, mutators.size() - 1); |
18 | 0 | return mutators.at(idist(rng))(data, size, maxSize, seed); |
19 | 0 | } |
20 | | |
21 | 0 | return LLVMFuzzerMutate(data, size, maxSize); |
22 | 0 | } |