diff options
author | Jasper St. Pierre <jstpierre@mecheye.net> | 2014-08-07 09:55:49 -0400 |
---|---|---|
committer | Pekka Paalanen <pekka.paalanen@collabora.co.uk> | 2014-08-21 13:51:07 +0300 |
commit | 78d80474073b6145f6f03dd4928c3a4daf9c6b9c (patch) | |
tree | dde53d203a299e046bf00ece8a544457c4186940 | |
parent | a52357f6fbfb5f531e91dc2eb85c93c86c2a628f (diff) |
server: Don't expose wl_display as a global
The idea here was that once upon a time, clients could rebind wl_display
to a higher version, so we offered the ability to rebind it
here. However, this is particularly broken. The existing bind
implementation actually still hardcodes version numbers, and it leaks
previous resources, overwriting the existing one.
The newly bound resource *also* won't have any listeners attached by the
client, meaning that the error and delete_id events won't get delivered
correctly. Unless the client poked into libwayland internals, it also
can't possibly set up these handlers correctly either, so the client
will sustain errors and leak all deleted globals.
Since this never worked correctly in the first place, we can feel safe
removing it.
Acked-by: Jason Ekstrand <jason@jlekstrand.net>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
-rw-r--r-- | src/wayland-server.c | 28 |
1 files changed, 8 insertions, 20 deletions
diff --git a/src/wayland-server.c b/src/wayland-server.c index 3bd8e68..674aeca 100644 --- a/src/wayland-server.c +++ b/src/wayland-server.c @@ -380,9 +380,8 @@ wl_client_get_display(struct wl_client *client) return client->display; } -static void -bind_display(struct wl_client *client, - void *data, uint32_t version, uint32_t id); +static int +bind_display(struct wl_client *client, struct wl_display *display); /** Create a client for the given file descriptor * @@ -440,9 +439,7 @@ wl_client_create(struct wl_display *display, int fd) goto err_map; wl_signal_init(&client->destroy_signal); - bind_display(client, display, 1, 1); - - if (!client->display_resource) + if (bind_display(client, display) < 0) goto err_map; wl_list_insert(display->client_list.prev, &client->link); @@ -772,22 +769,20 @@ destroy_client_display_resource(struct wl_resource *resource) resource->client->display_resource = NULL; } -static void -bind_display(struct wl_client *client, - void *data, uint32_t version, uint32_t id) +static int +bind_display(struct wl_client *client, struct wl_display *display) { - struct wl_display *display = data; - client->display_resource = - wl_resource_create(client, &wl_display_interface, 1, id); + wl_resource_create(client, &wl_display_interface, 1, 1); if (client->display_resource == NULL) { wl_client_post_no_memory(client); - return; + return -1; } wl_resource_set_implementation(client->display_resource, &display_interface, display, destroy_client_display_resource); + return 0; } /** Create Wayland display object. @@ -831,13 +826,6 @@ wl_display_create(void) wl_array_init(&display->additional_shm_formats); - if (!wl_global_create(display, &wl_display_interface, 1, - display, bind_display)) { - wl_event_loop_destroy(display->loop); - free(display); - return NULL; - } - return display; } |