Skip to content

Commit

Permalink
check for import
Browse files Browse the repository at this point in the history
  • Loading branch information
tlively committed Mar 7, 2024
1 parent c14d41b commit ad7c8d3
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/tools/fuzzing/fuzzing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -510,11 +510,16 @@ void TranslateToFuzzReader::finalizeTable() {
// If the offset contains a global that was imported (which is ok) but
// no longer is (not ok unless GC is enabled), we may need to change
// that.
if (!wasm.features.hasGC() &&
!FindAll<GlobalGet>(segment->offset).list.empty()) {
// TODO: the segments must not overlap...
segment->offset =
builder.makeConst(Literal::makeFromInt32(0, Type::i32));
if (!wasm.features.hasGC()) {
for (auto* get : FindAll<GlobalGet>(segment->offset).list) {
// N.B: We never currently encounter imported globals here, but we
// do the check for robustness.
if (!wasm.getGlobal(get->name)->imported()) {
// TODO: the segments must not overlap...
segment->offset =
builder.makeConst(Literal::makeFromInt32(0, Type::i32));
}
}
}
Address maxOffset = segment->data.size();
if (auto* offset = segment->offset->dynCast<Const>()) {
Expand Down

0 comments on commit ad7c8d3

Please sign in to comment.