Skip to content

Commit ad7c8d3

Browse files
committed
check for import
1 parent c14d41b commit ad7c8d3

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

src/tools/fuzzing/fuzzing.cpp

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -510,11 +510,16 @@ void TranslateToFuzzReader::finalizeTable() {
510510
// If the offset contains a global that was imported (which is ok) but
511511
// no longer is (not ok unless GC is enabled), we may need to change
512512
// that.
513-
if (!wasm.features.hasGC() &&
514-
!FindAll<GlobalGet>(segment->offset).list.empty()) {
515-
// TODO: the segments must not overlap...
516-
segment->offset =
517-
builder.makeConst(Literal::makeFromInt32(0, Type::i32));
513+
if (!wasm.features.hasGC()) {
514+
for (auto* get : FindAll<GlobalGet>(segment->offset).list) {
515+
// N.B: We never currently encounter imported globals here, but we
516+
// do the check for robustness.
517+
if (!wasm.getGlobal(get->name)->imported()) {
518+
// TODO: the segments must not overlap...
519+
segment->offset =
520+
builder.makeConst(Literal::makeFromInt32(0, Type::i32));
521+
}
522+
}
518523
}
519524
Address maxOffset = segment->data.size();
520525
if (auto* offset = segment->offset->dynCast<Const>()) {

0 commit comments

Comments
 (0)