From b4d7a5a1861dc5028f3b1dff0e8432a2829208f2 Mon Sep 17 00:00:00 2001 From: Marius Vlad Date: Thu, 29 Oct 2020 22:59:02 +0200 Subject: [PATCH] main: Use the output handler to destroy to black view Use the specific output destroyer handler, instead of destroying it in the handler itself. This way we can still clean-up and avoid any leaks, and still not trip ourselves causing a use-after-free, when the output is destroyed by libweston. Bug-AGL: SPEC-3630, SPEC-3672 Signed-off-by: Marius Vlad Reported-by: Walter Lozano Change-Id: I11916245b85d2541286ee438284601b466dc20c2 --- src/main.c | 5 +++++ src/shell.c | 7 +------ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main.c b/src/main.c index e85d788..8492f54 100644 --- a/src/main.c +++ b/src/main.c @@ -74,6 +74,11 @@ handle_output_destroy(struct wl_listener *listener, void *data) output = wl_container_of(listener, output, output_destroy); assert(output->output == data); + if (output->fullscreen_view.fs->view) { + weston_surface_destroy(output->fullscreen_view.fs->view->surface); + output->fullscreen_view.fs->view = NULL; + } + output->output = NULL; wl_list_remove(&output->output_destroy.link); } diff --git a/src/shell.c b/src/shell.c index e6fb332..40beef1 100644 --- a/src/shell.c +++ b/src/shell.c @@ -561,13 +561,8 @@ destroy_black_view(struct wl_listener *listener, void *data) if (fs && fs->fs) { - if (fs->fs->view && fs->fs->view->surface) { - weston_surface_destroy(fs->fs->view->surface); - fs->fs->view = NULL; - } - - free(fs->fs); wl_list_remove(&fs->fs_destroy.link); + free(fs->fs); } } -- 2.16.6