[PATCH] server: move memset after check

Pekka Paalanen ppaalanen at gmail.com
Thu Aug 7 06:08:24 PDT 2014


On Wed,  6 Aug 2014 11:28:34 +0200
Marek Chalupa <mchqwerty at gmail.com> wrote:

> If the malloc fails, memset would touch invalid memory.
> ---
>  src/wayland-server.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/src/wayland-server.c b/src/wayland-server.c
> index 75de313..3c162d4 100644
> --- a/src/wayland-server.c
> +++ b/src/wayland-server.c
> @@ -1150,10 +1150,11 @@ wl_display_add_socket_auto(struct wl_display *display)
>  	const int MAX_DISPLAYNO = 32;
>  
>  	s = malloc(sizeof *s);
> -	memset(s, 0, sizeof *s);
>  	if (s == NULL)
>  		return NULL;
>  
> +	memset(s, 0, sizeof *s);
> +
>  	do {
>  		snprintf(display_name, sizeof display_name, "wayland-%d", displayno);
>  		if (wl_socket_init_for_display_name(s, display_name) < 0) {


Hi,

patch pushed!


Thanks,
pq


More information about the wayland-devel mailing list