Skip to content

Commit 4ebde3f

Browse files
sjindel-googlecommit-bot@chromium.org
authored andcommitted
[vm] Fix missing null check in FLAG_force_evacuation.
Bug: #37772 Change-Id: I4e62dd0355fe0ebc7716de05a093142389067191 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/112403 Commit-Queue: Ryan Macnak <[email protected]> Reviewed-by: Ryan Macnak <[email protected]>
1 parent 271ad96 commit 4ebde3f

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

runtime/vm/heap/compactor.cc

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,11 +213,19 @@ void GCCompactor::Compact(HeapPage* pages,
213213
// objects move and all pages that used to have an object are released.
214214
// This can be helpful for finding untracked pointers because it prevents
215215
// an untracked pointer from getting lucky with its target not moving.
216-
for (intptr_t task_index = 0; task_index < num_tasks; task_index++) {
216+
bool oom = false;
217+
for (intptr_t task_index = 0; task_index < num_tasks && !oom;
218+
task_index++) {
217219
const intptr_t pages_per_task = num_pages / num_tasks;
218220
for (intptr_t j = 0; j < pages_per_task; j++) {
219221
HeapPage* page = heap_->old_space()->AllocatePage(HeapPage::kData,
220222
/* link */ false);
223+
224+
if (page == nullptr) {
225+
oom = true;
226+
break;
227+
}
228+
221229
FreeListElement::AsElement(page->object_start(),
222230
page->object_end() - page->object_start());
223231

0 commit comments

Comments
 (0)