From c7ed0064e73cc8c86db45a3c84936a0bc4602490 Mon Sep 17 00:00:00 2001 From: Changyeon Lee Date: Wed, 6 Jul 2016 13:11:31 +0900 Subject: [PATCH] free client resource in wayland_tbm_server_deinit Change-Id: I378e9eb324f3f135d77c6545b87da5bb4ffa44b3 --- src/wayland-tbm-server.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/wayland-tbm-server.c b/src/wayland-tbm-server.c index 483a69b..6bac14f 100644 --- a/src/wayland-tbm-server.c +++ b/src/wayland-tbm-server.c @@ -582,6 +582,8 @@ _wayland_tbm_server_destroy_resource(struct wl_resource *wl_tbm) /* remove the client resources to the list */ tbm_srv = wl_resource_get_user_data(wl_tbm); + if (!tbm_srv) return; + if (!wl_list_empty(&tbm_srv->cresource_list)) { wl_list_for_each_safe(c_res, tmp_res, &tbm_srv->cresource_list, link) { if (c_res->resource == wl_tbm) { @@ -679,8 +681,21 @@ wayland_tbm_server_init(struct wl_display *display, const char *device_name, void wayland_tbm_server_deinit(struct wayland_tbm_server *tbm_srv) { + struct wayland_tbm_client_resource *c_res = NULL, *tmp_res; + WL_TBM_RETURN_IF_FAIL(tbm_srv != NULL); + if (!wl_list_empty(&tbm_srv->cresource_list)) { + wl_list_for_each_safe(c_res, tmp_res, &tbm_srv->cresource_list, link) { + wl_list_remove(&c_res->link); + if (c_res->app_name) + free(c_res->app_name); + + wl_resource_set_user_data(c_res->resource, NULL); + free(c_res); + } + } + wl_global_destroy(tbm_srv->wl_tbm_global); tbm_bufmgr_deinit(tbm_srv->bufmgr); -- 2.7.4