[PATCH wayland 3/5] server: don't proceed in posting no-memory error on client destruction

Marek Chalupa mchqwerty at gmail.com
Fri May 13 13:01:20 UTC 2016


When a client is being destroyed, the display_resource is set to NULL.
If then some destroy handler calls wl_client_post_no_memory() or
wl_resource_post_no_memory() we crash.

Signed-off-by: Marek Chalupa <mchqwerty at gmail.com>
---
 src/wayland-server.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/src/wayland-server.c b/src/wayland-server.c
index c93a426..b26a48d 100644
--- a/src/wayland-server.c
+++ b/src/wayland-server.c
@@ -546,6 +546,11 @@ wl_client_get_object(struct wl_client *client, uint32_t id)
 WL_EXPORT void
 wl_client_post_no_memory(struct wl_client *client)
 {
+	/* don't send any other errors
+	 * if we are destroying the client */
+	if (!client->display_resource)
+		return;
+
 	wl_resource_post_error(client->display_resource,
 			       WL_DISPLAY_ERROR_NO_MEMORY, "no memory");
 }
@@ -553,6 +558,11 @@ wl_client_post_no_memory(struct wl_client *client)
 WL_EXPORT void
 wl_resource_post_no_memory(struct wl_resource *resource)
 {
+	/* don't send any other errors
+	 * if we are destroying the client */
+	if (!resource->client->display_resource)
+		return;
+
 	wl_resource_post_error(resource->client->display_resource,
 			       WL_DISPLAY_ERROR_NO_MEMORY, "no memory");
 }
-- 
2.5.5



More information about the wayland-devel mailing list