mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-20 15:19:07 +01:00
script/verify_flags: make script_verify_flags type safe
`using script_verify_flags = uint32_t` allows implicit conversion to and from int, so replace it with a class to have the compiler ensure we use the correct type. Provide from_int and as_int to allow for explicit conversions when desired. Introduces the type `script_verify_flag_name` for the individual flag name enumeration.
This commit is contained in:
@@ -118,8 +118,8 @@ FUZZ_TARGET(script, .init = initialize_script)
|
||||
(void)FindAndDelete(script_mut, *other_script);
|
||||
}
|
||||
const std::vector<std::string> random_string_vector = ConsumeRandomLengthStringVector(fuzzed_data_provider);
|
||||
const uint32_t u32{fuzzed_data_provider.ConsumeIntegral<uint32_t>()};
|
||||
const script_verify_flags flags{u32 | SCRIPT_VERIFY_P2SH};
|
||||
const auto flags_rand{fuzzed_data_provider.ConsumeIntegral<script_verify_flags::value_type>()};
|
||||
const auto flags = script_verify_flags::from_int(flags_rand) | SCRIPT_VERIFY_P2SH;
|
||||
{
|
||||
CScriptWitness wit;
|
||||
for (const auto& s : random_string_vector) {
|
||||
|
||||
Reference in New Issue
Block a user