free client resource in wayland_tbm_server_deinit 35/78535/1 accepted/tizen/common/20160707.171216 accepted/tizen/ivi/20160706.082953 accepted/tizen/mobile/20160706.082922 accepted/tizen/tv/20160706.082903 accepted/tizen/wearable/20160706.082914 submit/tizen/20160706.051650
authorChangyeon Lee <cyeon.lee@samsung.com>
Wed, 6 Jul 2016 04:11:31 +0000 (13:11 +0900)
committerChangyeon Lee <cyeon.lee@samsung.com>
Wed, 6 Jul 2016 04:11:31 +0000 (13:11 +0900)
Change-Id: I378e9eb324f3f135d77c6545b87da5bb4ffa44b3

src/wayland-tbm-server.c

index 483a69b..6bac14f 100644 (file)
@@ -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);