[PATCH 2/2] server: fix conditions for fds in wl_socket_destroy

Pekka Paalanen ppaalanen at gmail.com
Thu Aug 7 06:41:59 PDT 2014


On Wed,  6 Aug 2014 12:18:12 +0200
Marek Chalupa <mchqwerty at gmail.com> wrote:

> The only value that is false with the former condition is 0.
> On error we set fd to -1.
> ---
>  src/wayland-server.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/src/wayland-server.c b/src/wayland-server.c
> index ce7bbff..c8aecb8 100644
> --- a/src/wayland-server.c
> +++ b/src/wayland-server.c
> @@ -848,11 +848,11 @@ wl_socket_destroy(struct wl_socket *s)
>  		wl_event_source_remove(s->source);
>  	if (s->addr.sun_path[0])
>  		unlink(s->addr.sun_path);
> -	if (s->fd)
> +	if (s->fd > 0)
>  		close(s->fd);
>  	if (s->lock_addr[0])
>  		unlink(s->lock_addr);
> -	if (s->fd_lock)
> +	if (s->fd_lock > 0)
>  		close(s->fd_lock);
>  
>  	free(s);

Hi,

also fd 0 is valid. Unfortunately, allowing to close fd 0 here leads to
'make check' failure, as the test accidentally closes stdout_fileno,
because the fds are not initialized to -1.

I will send a replacement patch.


Thanks,
pq


More information about the wayland-devel mailing list