[PATCH 1/2] terminal: Only set title if asprintf succeeded

Kristian Høgsberg hoegsberg at gmail.com
Fri Jan 17 11:30:15 PST 2014


On Tue, Jan 14, 2014 at 09:58:32PM +0000, Bryce W. Harrington wrote:
> Handles potential out of memory situation by skipping the title update.
> This fixes the following warning:
> 
>   terminal.c: In function ‘resize_handler’:
>   terminal.c:851:11: warning: ignoring return value of ‘asprintf’,
>   declared with attribute warn_unused_result [-Wunused-result]
> 
> Signed-off-by: Bryce Harrington <b.harrington at samsung.com>

That looks good, thanks.  Committed.

Kristian

> ---
>  clients/terminal.c |    7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/clients/terminal.c b/clients/terminal.c
> index e2a6236..09bc321 100644
> --- a/clients/terminal.c
> +++ b/clients/terminal.c
> @@ -848,9 +848,10 @@ resize_handler(struct widget *widget,
>  		width = columns * terminal->average_width + m;
>  		height = rows * terminal->extents.height + m;
>  		widget_set_size(terminal->widget, width, height);
> -		asprintf(&p, "%s — [%dx%d]", terminal->title, columns, rows);
> -		window_set_title(terminal->window, p);
> -		free(p);
> +		if (asprintf(&p, "%s — [%dx%d]", terminal->title, columns, rows) > 0) {
> +		    window_set_title(terminal->window, p);
> +		    free(p);
> +		}
>  	}
>  
>  	terminal_resize_cells(terminal, columns, rows);
> -- 
> 1.7.9.5
> _______________________________________________
> 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