diff options
author | Mathias Fiedler <mathias.fiedler@xse.de> | 2012-07-18 15:51:45 +0200 |
---|---|---|
committer | Kristian Høgsberg <krh@bitplanet.net> | 2012-07-22 14:06:37 -0400 |
commit | 900e4b63ef185767a4f1f1eea0ea1fb9899b4da5 (patch) | |
tree | f849a005beb4687b0d4a7f2fb3a175e76d752e0e | |
parent | 76bfd68f47c6cd8552151aa90efc4e5d074d14f9 (diff) |
wayland-server: send error on invalid new object id
Creation of new client resources was silently ignored when
wl_client_add_resource() was used on server side and new object id was out
of range.
An error is now send out to the client in such case.
Also changed error message in wl_client_add_object, since
wl_map_insert_at() returns -1 only at invalid new id.
-rw-r--r-- | src/wayland-server.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/wayland-server.c b/src/wayland-server.c index df9bd07..3dc8416 100644 --- a/src/wayland-server.c +++ b/src/wayland-server.c @@ -395,9 +395,12 @@ wl_client_add_resource(struct wl_client *client, resource->object.id = wl_map_insert_new(&client->objects, WL_MAP_SERVER_SIDE, resource); - else - wl_map_insert_at(&client->objects, - resource->object.id, resource); + else if (wl_map_insert_at(&client->objects, + resource->object.id, resource) < 0) + wl_resource_post_error(client->display_resource, + WL_DISPLAY_ERROR_INVALID_OBJECT, + "invalid new id %d", + resource->object.id); resource->client = client; wl_signal_init(&resource->destroy_signal); @@ -1277,7 +1280,10 @@ wl_client_add_object(struct wl_client *client, wl_signal_init(&resource->destroy_signal); if (wl_map_insert_at(&client->objects, resource->object.id, resource) < 0) { - wl_resource_post_no_memory(client->display_resource); + wl_resource_post_error(client->display_resource, + WL_DISPLAY_ERROR_INVALID_OBJECT, + "invalid new id %d", + resource->object.id); free(resource); return NULL; } |