client: Consume file descriptors destined for zombie proxies

We need to close file descriptors sent to zombie proxies to avoid leaking
them, and perhaps more importantly, to prevent them from being dispatched
in events on other objects (since they would previously be left in the
buffer and potentially fed to following events destined for live proxies)

Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
This commit is contained in:
Derek Foreman 2017-12-06 11:22:23 -06:00 committed by Daniel Stone
parent 4485ed1f59
commit 239ba39331
3 changed files with 17 additions and 0 deletions

View file

@ -192,6 +192,12 @@ close_fds(struct wl_buffer *buffer, int max)
buffer->tail += size;
}
void
wl_connection_close_fds_in(struct wl_connection *connection, int max)
{
close_fds(&connection->fds_in, max);
}
int
wl_connection_destroy(struct wl_connection *connection)
{

View file

@ -1353,8 +1353,16 @@ queue_event(struct wl_display *display, int len)
if (len < size)
return 0;
/* If our proxy is gone or a zombie, just eat the event (and any FDs,
* if applicable). */
proxy = wl_map_lookup(&display->objects, id);
if (!proxy || wl_object_is_zombie(&display->objects, id)) {
struct wl_zombie *zombie = wl_map_lookup(&display->objects, id);
if (zombie)
wl_connection_close_fds_in(display->connection,
zombie->fd_count[opcode]);
wl_connection_consume(display->connection, size);
return size;
}

View file

@ -253,4 +253,7 @@ wl_priv_signal_get(struct wl_priv_signal *signal, wl_notify_func_t notify);
void
wl_priv_signal_emit(struct wl_priv_signal *signal, void *data);
void
wl_connection_close_fds_in(struct wl_connection *connection, int max);
#endif