This patch fixes memory corruption caused by removing
ds_xdg_surfaces's link in destroy_xdg_surface().
When wl_client is destroyed, ds_xdg_shell_client can be destroyed
before its own ds_xdg_surfaces. This led to memory corruption because of
illegal access to a freed memory when trying to remove list of
ds_xdg_surface.link.
Change-Id: I2558e445af25e85a84f761f845dae22eb10eeab4
xdg_client_handle_resource_destroy(struct wl_resource *resource)
{
struct ds_xdg_client *client;
+ struct ds_xdg_surface *surface, *tmp;
client = wl_resource_get_user_data(resource);
+ wl_list_for_each_safe(surface, tmp, &client->surfaces, link)
+ destroy_xdg_surface(surface);
+
if (client->ping_timer != NULL)
wl_event_source_remove(client->ping_timer);
create_xdg_surface(struct ds_xdg_client *client, struct ds_surface *surface,
uint32_t id);
+void destroy_xdg_surface(struct ds_xdg_surface *surface);
+
void
reset_xdg_surface(struct ds_xdg_surface *surface);