[PATCH weston 2/2] terminal.c: check if fdopen() fails

Kristian Høgsberg hoegsberg at gmail.com
Wed Aug 7 16:29:02 PDT 2013


On Wed, Aug 07, 2013 at 03:35:00PM -0700, Brian Lovin wrote:
> We never verify that fdopen() succeeds in terminal_send_selection().
> 
> Signed-off-by: Brian Lovin <brian.j.lovin at intel.com>
> ---
>  clients/terminal.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/clients/terminal.c b/clients/terminal.c
> index 1cc26d0..5f9ee55 100644
> --- a/clients/terminal.c
> +++ b/clients/terminal.c
> @@ -843,6 +843,10 @@ terminal_send_selection(struct terminal *terminal, int fd)
>  	int len;
>  
>  	fp = fdopen(fd, "w");
> +	if (fp == NULL){
> +		fprintf(stderr, "terminal: fdopen failed\n");
> +		exit(EXIT_FAILURE);
> +	}

We need to handle fp == NULL, but maybe we could just close fd and
return (and thus failing the copy-and-paste) instead of exiting the
entire terminal?

Kristian


>  	for (row = 0; row < terminal->height; row++) {
>  		p_row = terminal_get_row(terminal, row);
>  		for (col = 0; col < terminal->width; col++) {
> -- 
> 1.8.1.2
> 
> _______________________________________________
> wayland-devel mailing list
> wayland-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/wayland-devel


More information about the wayland-devel mailing list