diff --git a/runtime/vm/heap/scavenger.cc b/runtime/vm/heap/scavenger.cc index 526fb5a9846..10d65b85969 100644 --- a/runtime/vm/heap/scavenger.cc +++ b/runtime/vm/heap/scavenger.cc @@ -1432,11 +1432,11 @@ void Scavenger::MournWeakTables() { auto replacement = raw_obj->IsNewObject() ? replacement_new : replacement_old; replacement->SetValueExclusive(raw_obj, table->ValueAtExclusive(i)); - } - } else { - // The object has been collected. - if (cleanup != nullptr) { - cleanup(reinterpret_cast(table->ValueAtExclusive(i))); + } else { + // The object has been collected. + if (cleanup != nullptr) { + cleanup(reinterpret_cast(table->ValueAtExclusive(i))); + } } } }