[PATCH 2/3] shm: Do not attempt mmap if no file descriptor was received

Lubomir Rintel lkundrak at v3.sk
Fri Nov 15 05:17:55 PST 2013


This is just for the sake of  cleanliness and correct error handling.
Without this the mmap would fail emitting an error message about failed
mapping to the client and a close of bogus file descriptor would be
attempted, which is harmless since it can not fail.

Signed-off-by: Lubomir Rintel <lkundrak at v3.sk>
---
 src/wayland-shm.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/src/wayland-shm.c b/src/wayland-shm.c
index 28f52f4..ad92dba 100644
--- a/src/wayland-shm.c
+++ b/src/wayland-shm.c
@@ -220,6 +220,13 @@ shm_create_pool(struct wl_client *client, struct wl_resource *resource,
 {
 	struct wl_shm_pool *pool;
 
+	if (fd < 0) {
+		wl_resource_post_error(resource,
+				       WL_SHM_ERROR_INVALID_FD,
+				       "file descriptor expected");
+		return;
+	}
+
 	pool = malloc(sizeof *pool);
 	if (pool == NULL) {
 		wl_client_post_no_memory(client);
-- 
1.8.4.2



More information about the wayland-devel mailing list