mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-11-22 12:55:58 +01:00
security-context-v1: fix possible leaks on wl_client_create() and state copying errors
This commit is contained in:
parent
d18670b922
commit
58bb49a00b
1 changed files with 16 additions and 9 deletions
|
@ -100,13 +100,18 @@ static void security_context_destroy(
|
||||||
free(security_context);
|
free(security_context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void security_context_client_destroy(
|
||||||
|
struct wlr_security_context_v1_client *security_context_client) {
|
||||||
|
wl_list_remove(&security_context_client->destroy.link);
|
||||||
|
security_context_state_finish(&security_context_client->state);
|
||||||
|
free(security_context_client);
|
||||||
|
}
|
||||||
|
|
||||||
static void security_context_client_handle_destroy(struct wl_listener *listener,
|
static void security_context_client_handle_destroy(struct wl_listener *listener,
|
||||||
void *data) {
|
void *data) {
|
||||||
struct wlr_security_context_v1_client *security_context_client =
|
struct wlr_security_context_v1_client *security_context_client =
|
||||||
wl_container_of(listener, security_context_client, destroy);
|
wl_container_of(listener, security_context_client, destroy);
|
||||||
wl_list_remove(&security_context_client->destroy.link);
|
security_context_client_destroy(security_context_client);
|
||||||
security_context_state_finish(&security_context_client->state);
|
|
||||||
free(security_context_client);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int security_context_handle_listen_fd_event(int listen_fd, uint32_t mask,
|
static int security_context_handle_listen_fd_event(int listen_fd, uint32_t mask,
|
||||||
|
@ -139,17 +144,19 @@ static int security_context_handle_listen_fd_event(int listen_fd, uint32_t mask,
|
||||||
if (client == NULL) {
|
if (client == NULL) {
|
||||||
wlr_log(WLR_ERROR, "wl_client_create failed");
|
wlr_log(WLR_ERROR, "wl_client_create failed");
|
||||||
close(client_fd);
|
close(client_fd);
|
||||||
return 0;
|
free(security_context_client);
|
||||||
}
|
|
||||||
|
|
||||||
if (!security_context_state_copy(&security_context_client->state,
|
|
||||||
&security_context->state)) {
|
|
||||||
wl_client_post_no_memory(client);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
security_context_client->destroy.notify = security_context_client_handle_destroy;
|
security_context_client->destroy.notify = security_context_client_handle_destroy;
|
||||||
wl_client_add_destroy_listener(client, &security_context_client->destroy);
|
wl_client_add_destroy_listener(client, &security_context_client->destroy);
|
||||||
|
|
||||||
|
if (!security_context_state_copy(&security_context_client->state,
|
||||||
|
&security_context->state)) {
|
||||||
|
security_context_client_destroy(security_context_client);
|
||||||
|
wl_client_post_no_memory(client);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Reference in a new issue