Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 0c74fc9

Browse files
authored
[fuchsia] Fix use-after-free (#4987)
We were trying to re-establish the wait after calling Reset(), but Reset() can result in the surface being destroyed. Now we re-establish the wait inside the Reset() machinery.
1 parent b6d2dde commit 0c74fc9

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

content_handler/vulkan_surface.cc

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,6 @@ VulkanSurface::VulkanSurface(vulkan::VulkanProvider& vulkan_provider,
4444

4545
wait_.set_object(release_event_.get());
4646
wait_.set_trigger(ZX_EVENT_SIGNALED);
47-
wait_.Begin(async_get_default());
48-
49-
// Probably not necessary as the events should be in the unsignalled state
50-
// already.
5147
Reset();
5248

5349
valid_ = true;
@@ -398,6 +394,8 @@ void VulkanSurface::Reset() {
398394
FXL_DLOG(ERROR) << "failed to create acquire semaphore";
399395
}
400396

397+
wait_.Begin(async_get_default());
398+
401399
// It is safe for the caller to collect the surface in the callback.
402400
auto callback = pending_on_writes_committed_;
403401
pending_on_writes_committed_ = nullptr;
@@ -415,7 +413,6 @@ void VulkanSurface::OnHandleReady(async_t* async,
415413
return;
416414
FXL_DCHECK(signal->observed & ZX_EVENT_SIGNALED);
417415
Reset();
418-
wait->Begin(async);
419416
}
420417

421418
} // namespace flutter_runner

0 commit comments

Comments
 (0)