Commit 713cc2e0 authored by Kramer Ge's avatar Kramer Ge Committed by Commit Bot

[ozone/wayland] MockSurface should destroy its role upon destruction

TestSubsurface has a ptr to MockSurface wl_resource which may incur
use-after-free if MockSurface is destroyed first. Do the same thing we
do for MockXdgSurface in MockSurface dtor to avoid it.

Change-Id: Ia63c187485c39033f715f446cc724fcc4043b46a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2391388Reviewed-by: default avatarMaksim Sisov (GMT+3) <msisov@igalia.com>
Reviewed-by: default avatarTakashi Sakamoto <tasak@google.com>
Commit-Queue: Kramer Ge <fangzhoug@chromium.org>
Cr-Commit-Position: refs/heads/master@{#805289}
parent b1428bf8
...@@ -87,6 +87,8 @@ MockSurface::MockSurface(wl_resource* resource) : ServerObject(resource) {} ...@@ -87,6 +87,8 @@ MockSurface::MockSurface(wl_resource* resource) : ServerObject(resource) {}
MockSurface::~MockSurface() { MockSurface::~MockSurface() {
if (xdg_surface_ && xdg_surface_->resource()) if (xdg_surface_ && xdg_surface_->resource())
wl_resource_destroy(xdg_surface_->resource()); wl_resource_destroy(xdg_surface_->resource());
if (sub_surface_ && sub_surface_->resource())
wl_resource_destroy(sub_surface_->resource());
} }
MockSurface* MockSurface::FromResource(wl_resource* resource) { MockSurface* MockSurface::FromResource(wl_resource* resource) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment