server: correct wrong freeing 90/161390/1
authorBoram Park <boram1288.park@samsung.com>
Thu, 23 Nov 2017 05:39:47 +0000 (14:39 +0900)
committerBoram Park <boram1288.park@samsung.com>
Thu, 23 Nov 2017 06:45:28 +0000 (15:45 +0900)
Change-Id: I60595fa61f80ada4c4f2586eef8537cf38c04446

src/tdm_server.c

index b193ac6..b11911d 100644 (file)
@@ -87,6 +87,7 @@ typedef struct _tdm_server_client_info {
        struct list_head link;
        pid_t pid;
        char name[TDM_NAME_LEN];
+       struct wl_resource *resource;
 } tdm_server_client_info;
 
 static tdm_private_server *keep_private_server;
@@ -700,15 +701,12 @@ destroy_client(struct wl_resource *resource)
 {
        tdm_server_client_info *c = NULL, *cc = NULL;
        struct wl_client *client;
-       pid_t pid = -1;
 
        client = wl_resource_get_client(resource);
        TDM_RETURN_IF_FAIL(client != NULL);
 
-       wl_client_get_credentials(client, &pid, NULL, NULL);
-
        LIST_FOR_EACH_ENTRY_SAFE(c, cc, &client_list, link) {
-               if (c->pid == pid) {
+               if (c->resource == resource) {
                        LIST_DEL(&c->link);
                        free(c);
                        return;
@@ -736,6 +734,8 @@ _tdm_server_bind(struct wl_client *client, void *data,
                return;
        }
 
+       cinfo->resource = resource;
+
        LIST_ADDTAIL(&cinfo->link, &client_list);
        wl_client_get_credentials(client, &cinfo->pid, NULL, NULL);
        _tdm_server_get_process_name(cinfo->pid, cinfo->name, TDM_NAME_LEN);
@@ -907,14 +907,13 @@ tdm_server_deinit(tdm_private_loop *private_loop)
                wl_resource_destroy(o->resource);
        }
 
+       LIST_FOR_EACH_ENTRY_SAFE(c, cc, &client_list, link) {
+               wl_resource_destroy(c->resource);
+       }
+
        free(private_server);
        private_loop->private_server = NULL;
        keep_private_server = NULL;
-
-       LIST_FOR_EACH_ENTRY_SAFE(c, cc, &client_list, link) {
-               LIST_DEL(&c->link);
-               free(c);
-       }
 }
 
 INTERN const char*