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:
Alastair Donaldson 2021-07-01 14:51:13 +00:00 committed by GitHub
parent 74e8105eb8
commit 06f114d482
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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)];