Skip to content

Commit

Permalink
[fuchsia] Fix use-after-free (flutter#4987)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
abarth authored Apr 12, 2018
1 parent b6d2dde commit 0c74fc9
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions content_handler/vulkan_surface.cc
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,6 @@ VulkanSurface::VulkanSurface(vulkan::VulkanProvider& vulkan_provider,

wait_.set_object(release_event_.get());
wait_.set_trigger(ZX_EVENT_SIGNALED);
wait_.Begin(async_get_default());

// Probably not necessary as the events should be in the unsignalled state
// already.
Reset();

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

wait_.Begin(async_get_default());

// It is safe for the caller to collect the surface in the callback.
auto callback = pending_on_writes_committed_;
pending_on_writes_committed_ = nullptr;
Expand All @@ -415,7 +413,6 @@ void VulkanSurface::OnHandleReady(async_t* async,
return;
FXL_DCHECK(signal->observed & ZX_EVENT_SIGNALED);
Reset();
wait->Begin(async);
}

} // namespace flutter_runner

0 comments on commit 0c74fc9

Please sign in to comment.