mirror of
https://github.com/KhronosGroup/SPIRV-Tools
synced 2024-12-26 01:31:06 +00:00
spirv-fuzz: Avoid out of bounds access (#4355)
In the extreme case where there are no basic types, FuzzerPassPushIdsThroughVariables could trigger a bounds error. This change fixes this problem.
This commit is contained in:
parent
74e8105eb8
commit
06f114d482
@ -69,6 +69,12 @@ void FuzzerPassPushIdsThroughVariables::Apply() {
|
||||
auto basic_type_ids_and_pointers =
|
||||
GetAvailableBasicTypesAndPointers(variable_storage_class);
|
||||
auto& basic_types = basic_type_ids_and_pointers.first;
|
||||
|
||||
// There must be at least some basic types.
|
||||
if (basic_types.empty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
uint32_t basic_type_id =
|
||||
basic_types[GetFuzzerContext()->RandomIndex(basic_types)];
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user