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

Submitted by Marek Chalupa on Dec. 5, 2014, 12:49 p.m.

Details

Message ID 1417783782-12792-3-git-send-email-mchqwerty@gmail.com
State Superseded
Headers show

Not browsing as part of any series.

Commit Message

Marek Chalupa Dec. 5, 2014, 12:49 p.m.
The fd member of clipboard_source structure was not set
but was used in close().

Signed-off-by: Marek Chalupa <mchqwerty@gmail.com>
---
 src/clipboard.c | 4 ++++
 1 file changed, 4 insertions(+)

Patch hide | download patch | download mbox

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;
@@ -151,6 +152,7 @@  clipboard_source_create(struct clipboard *clipboard,
 	source->refcount = 1;
 	source->clipboard = clipboard;
 	source->serial = serial;
+	source->fd = fd;
 
 	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;
+
 		clipboard_source_unref(client->source);
 		free(client);
 	}

Comments

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@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);
>  	}
>