Xwayland: fix possible use-after-free on unmap

The view.unmap() call may synchronously destroy the view, which makes
the the code removing listeners which is currently run after
view.unmap() access free'd memory.

To fix this, simply change the order of the calls to match that of
XdgToplevel.handleUnmap().
This commit is contained in:
Isaac Freund 2021-08-09 16:40:45 +02:00
parent 556d790694
commit 7013bc3b69
No known key found for this signature in database
GPG key ID: 86DED400DDFD7A11

View file

@ -214,12 +214,12 @@ fn handleMap(listener: *wl.Listener(*wlr.XwaylandSurface), xwayland_surface: *wl
fn handleUnmap(listener: *wl.Listener(*wlr.XwaylandSurface), xwayland_surface: *wlr.XwaylandSurface) void {
const self = @fieldParentPtr(Self, "unmap", listener);
self.view.unmap();
// Remove listeners that are only active while mapped
self.commit.link.remove();
self.set_title.link.remove();
self.set_class.link.remove();
self.view.unmap();
}
fn handleRequestConfigure(