Index: src/heap/mark-compact.cc |
diff --git a/src/heap/mark-compact.cc b/src/heap/mark-compact.cc |
index 4ca1443c7ae139b425efff470e10d6869afcbd3a..7c08ea0eb23348599643e673bd07dd4dd841debc 100644 |
--- a/src/heap/mark-compact.cc |
+++ b/src/heap/mark-compact.cc |
@@ -2266,8 +2266,9 @@ void MarkCompactCollector::VisitAllObjects(HeapObjectVisitor* visitor) { |
SpaceIterator space_it(heap()); |
HeapObject* obj = nullptr; |
while (space_it.has_next()) { |
- ObjectIterator* it = space_it.next(); |
- while ((obj = it->Next()) != nullptr) { |
+ std::unique_ptr<ObjectIterator> it(space_it.next()->GetObjectIterator()); |
+ ObjectIterator* obj_it = it.get(); |
+ while ((obj = obj_it->Next()) != nullptr) { |
visitor->Visit(obj); |
} |
} |