From 165a572512636bbc56877b834033428cca22a084 Mon Sep 17 00:00:00 2001 From: Seunghun Lee Date: Mon, 17 Jul 2023 13:33:23 +0900 Subject: [PATCH] server: Fix dereference after null check The closure could be referenced after null check. Change-Id: Icf49ed92f0000de2e28777e449eb5093a8b1a293 --- src/wayland-server.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/wayland-server.c b/src/wayland-server.c index 06cf212..4e645db 100644 --- a/src/wayland-server.c +++ b/src/wayland-server.c @@ -484,11 +484,19 @@ wl_client_connection_data(int fd, uint32_t mask, void *data) if (closure == NULL && errno == ENOMEM) { wl_resource_post_no_memory(resource); break; + } else if (closure == NULL) { + wl_resource_post_error(client->display_resource, + WL_DISPLAY_ERROR_INVALID_METHOD, + "invalid arguments for %s@%u.%s", + object->interface->name, + object->id, + message->name); + break; } else { pthread_mutex_lock(&client->objects_mutex); int lookup_ret = wl_closure_lookup_objects(closure, &client->objects); pthread_mutex_unlock(&client->objects_mutex); - if (closure == NULL || lookup_ret < 0) { + if (lookup_ret < 0) { wl_resource_post_error(client->display_resource, WL_DISPLAY_ERROR_INVALID_METHOD, "invalid arguments for %s@%u.%s", -- 2.7.4