File tree Expand file tree Collapse file tree 2 files changed +10
-7
lines changed Expand file tree Collapse file tree 2 files changed +10
-7
lines changed Original file line number Diff line number Diff line change 14
14
#define LLVM_FUZZER_FUZZED_DATA_PROVIDER_H_
15
15
16
16
#include < algorithm>
17
+ #include < array>
17
18
#include < climits>
18
19
#include < cstddef>
19
20
#include < cstdint>
@@ -71,6 +72,8 @@ class FuzzedDataProvider {
71
72
72
73
// Returns a value from the given array.
73
74
template <typename T, size_t size> T PickValueInArray (const T (&array)[size]);
75
+ template <typename T, size_t size>
76
+ T PickValueInArray (const std::array<T, size> &array);
74
77
template <typename T> T PickValueInArray (std::initializer_list<const T> list);
75
78
76
79
// Writes data to the given destination and returns number of bytes written.
@@ -301,6 +304,12 @@ T FuzzedDataProvider::PickValueInArray(const T (&array)[size]) {
301
304
return array[ConsumeIntegralInRange<size_t >(0 , size - 1 )];
302
305
}
303
306
307
+ template <typename T, size_t size>
308
+ T FuzzedDataProvider::PickValueInArray (const std::array<T, size> &array) {
309
+ static_assert (size > 0 , " The array must be non empty." );
310
+ return array[ConsumeIntegralInRange<size_t >(0 , size - 1 )];
311
+ }
312
+
304
313
template <typename T>
305
314
T FuzzedDataProvider::PickValueInArray (std::initializer_list<const T> list) {
306
315
// TODO(Dor1s): switch to static_assert once C++14 is allowed.
Original file line number Diff line number Diff line change @@ -34,12 +34,6 @@ constexpr FeeEstimateHorizon ALL_FEE_EST_HORIZON[] = {
34
34
FeeEstimateHorizon::MED_HALFLIFE,
35
35
FeeEstimateHorizon::LONG_HALFLIFE,
36
36
};
37
-
38
- constexpr OutputType ALL_OUTPUT_TYPE[] = {
39
- OutputType::LEGACY,
40
- OutputType::P2SH_SEGWIT,
41
- OutputType::BECH32,
42
- };
43
37
}; // namespace
44
38
45
39
// The fuzzing kitchen sink: Fuzzing harness for functions that need to be
@@ -56,7 +50,7 @@ FUZZ_TARGET(kitchen_sink)
56
50
57
51
(void )StringForFeeEstimateHorizon (fuzzed_data_provider.PickValueInArray (ALL_FEE_EST_HORIZON));
58
52
59
- const OutputType output_type = fuzzed_data_provider.PickValueInArray (ALL_OUTPUT_TYPE );
53
+ const OutputType output_type = fuzzed_data_provider.PickValueInArray (OUTPUT_TYPES );
60
54
const std::string& output_type_string = FormatOutputType (output_type);
61
55
OutputType output_type_parsed;
62
56
const bool parsed = ParseOutputType (output_type_string, output_type_parsed);
You can’t perform that action at this time.
0 commit comments