if display_resource = wl_resource_create() fails in bind_display(), we call wl_client_post_no_memory() which is wrong, since this function uses display_resource (which is NULL at this point). So remove call to this function (said simply: don't send an error to resource that you've just failed to create).
Also add a check to wl_client_post_no_memory() for display_resource. display_resource is destroyed first and only upon client's destruction, so it is a good marker that the client is being destroyed. Adding a check for display_resource here makes sure that we won't crash if some resource destructor or destroy signal handler calls wl_client_post_no_memory() while destroying client. https://bugs.freedesktop.org/show_bug.cgi?id=91356 Reported-by: Ashim <[email protected]> Signed-off-by: Marek Chalupa <[email protected]> --- src/wayland-server.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/wayland-server.c b/src/wayland-server.c index 1364d5d..b372aa9 100644 --- a/src/wayland-server.c +++ b/src/wayland-server.c @@ -511,6 +511,14 @@ wl_client_get_object(struct wl_client *client, uint32_t id) WL_EXPORT void wl_client_post_no_memory(struct wl_client *client) { + /* display_resource is destroyed first upon client's destruction + * If some resource destructor calls wl_client_post_no_memory() + * (why it would do it? you never know...), we would pass NULL + * here as a resource to the wl_resource_post_error + * and we don't want that */ + if (!client->display_resource) + return; + wl_resource_post_error(client->display_resource, WL_DISPLAY_ERROR_NO_MEMORY, "no memory"); } @@ -779,7 +787,8 @@ bind_display(struct wl_client *client, struct wl_display *display) client->display_resource = wl_resource_create(client, &wl_display_interface, 1, 1); if (client->display_resource == NULL) { - wl_client_post_no_memory(client); + /* Don't send error to client - + * what resource we would use anyway? */ return -1; } -- 2.5.0 _______________________________________________ wayland-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/wayland-devel
