wayland-server: Fix issue detected by static analysis tool 17/295517/1 accepted/tizen/unified/20230713.143456
authorInhong Han <inhong1.han@samsung.com>
Mon, 10 Jul 2023 06:46:50 +0000 (15:46 +0900)
committerInhong Han <inhong1.han@samsung.com>
Mon, 10 Jul 2023 06:47:00 +0000 (15:47 +0900)
double_initialization: pthread_mutex_init initializes client->objects_mutex while it is already initialized.

Change-Id: I5241c681ad4615605419a142bd5800b6d38b1072

src/wayland-server.c

index b60697e..a1ecca5 100644 (file)
@@ -659,6 +659,9 @@ wl_client_create(struct wl_display *display, int fd)
 
        wl_map_init(&client->objects, WL_MAP_SERVER_SIDE);
 
+       pthread_mutex_init(&client->connection_mutex, NULL);
+       pthread_mutex_init(&client->objects_mutex, NULL);
+
        if (wl_map_insert_at(&client->objects, 0, 0, NULL) < 0)
                goto err_map;
 
@@ -668,9 +671,6 @@ wl_client_create(struct wl_display *display, int fd)
 
        wl_client_get_process_name(client);
 
-       pthread_mutex_init(&client->connection_mutex, NULL);
-       pthread_mutex_init(&client->objects_mutex, NULL);
-
        wl_list_insert(display->client_list.prev, &client->link);
 
        wl_priv_signal_emit(&display->create_client_signal, client);
@@ -680,6 +680,8 @@ wl_client_create(struct wl_display *display, int fd)
 err_map:
        wl_map_release(&client->objects);
        wl_connection_destroy(client->connection);
+       pthread_mutex_destroy(&client->objects_mutex);
+       pthread_mutex_destroy(&client->connection_mutex);
 err_source:
        wl_event_source_remove(client->source);
 err_client: