[PATCH weston 3/3] clipboard: set fd member of clipboard_source

Derek Foreman derekf at osg.samsung.com
Tue Dec 9 08:59:27 PST 2014


On 05/12/14 06:49 AM, Marek Chalupa wrote:
> The fd member of clipboard_source structure was not set
> but was used in close().
> 
> Signed-off-by: Marek Chalupa <mchqwerty at gmail.com>
> ---
>  src/clipboard.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/src/clipboard.c b/src/clipboard.c
> index dbd8c9b..a9747b9 100644
> --- a/src/clipboard.c
> +++ b/src/clipboard.c
> @@ -63,6 +63,7 @@ clipboard_source_unref(struct clipboard_source *source)
>  		wl_event_source_remove(source->event_source);
>  		close(source->fd);
>  	}
> +
>  	wl_signal_emit(&source->base.destroy_signal,
>  		       &source->base);
>  	s = source->base.mime_types.data;

^ I'd drop the whitespace only hunk as unrelated...

> @@ -151,6 +152,7 @@ clipboard_source_create(struct clipboard *clipboard,
>  	source->refcount = 1;
>  	source->clipboard = clipboard;
>  	source->serial = serial;
> +	source->fd = fd;
>  

LGTM

>  	s = wl_array_add(&source->base.mime_types, sizeof *s);
>  	if (s == NULL)
> @@ -199,6 +201,8 @@ clipboard_client_data(int fd, uint32_t mask, void *data)
>  	if (client->offset == size || len <= 0) {
>  		close(fd);
>  		wl_event_source_remove(client->event_source);
> +		client->event_source = NULL;
> +

What's this for?  We're about to free client anyway...

>  		clipboard_source_unref(client->source);
>  		free(client);
>  	}
> 



More information about the wayland-devel mailing list