Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix
  • Loading branch information
kripken committed Apr 15, 2024
commit 226d3f18220cec1cba37a25fa60dde7acd83b9af
26 changes: 14 additions & 12 deletions src/tools/fuzzing/fuzzing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2450,18 +2450,20 @@ Expression* TranslateToFuzzReader::makeRefFuncConst(Type type) {
}
// Look for a proper function starting from a random location, and loop from
// there, wrapping around to 0.
Index start = upTo(wasm.functions.size());
Index i = start;
do {
auto& func = wasm.functions[i];
if (Type::isSubType(Type(func->type, NonNullable), type)) {
return builder.makeRefFunc(func->name, func->type);
}
i++;
if (i == wasm.functions.size()) {
i == 0;
}
} while (i != start);
if (!wasm.functions.empty()) {
Index start = upTo(wasm.functions.size());
Index i = start;
do {
auto& func = wasm.functions[i];
if (Type::isSubType(Type(func->type, NonNullable), type)) {
return builder.makeRefFunc(func->name, func->type);
}
i++;
if (i == wasm.functions.size()) {
i = 0;
}
} while (i != start);
}
// We don't have a matching function. Create a null some of the time here,
// but only rarely if the type is non-nullable (because in that case we'd need
// to add a ref.as_non_null to validate, and the code will trap when we get
Expand Down