[PATCH] server: Fix possible wl_display_add_socket_fd memleak

Bryce Harrington bryce at osg.samsung.com
Tue Feb 2 00:56:27 UTC 2016


On Mon, Feb 01, 2016 at 02:57:08PM -0600, Derek Foreman wrote:
> On 01/02/16 12:35 PM, Sergi Granell wrote:
> > If wl_event_loop_add_fd failed, the fail path didn't free the
> > newly allocated struct wl_socket.
> 
> Looks good to me:
> Reviewed-by: Derek Foreman <derekf at osg.samsung.com>

Pushed:
To ssh://git.freedesktop.org/git/wayland/wayland
   14b76a0..ac36082  master -> master
 
> > ---
> >  src/wayland-server.c | 9 +++++----
> >  1 file changed, 5 insertions(+), 4 deletions(-)
> > 
> > diff --git a/src/wayland-server.c b/src/wayland-server.c
> > index 6654cd7..3ba8a5d 100644
> > --- a/src/wayland-server.c
> > +++ b/src/wayland-server.c
> > @@ -1268,17 +1268,18 @@ wl_display_add_socket_fd(struct wl_display *display, int sock_fd)
> >  	if (s == NULL)
> >  		return -1;
> >  
> > -	/* Reuse the existing fd */
> > -	s->fd = sock_fd;
> > -
> > -	s->source = wl_event_loop_add_fd(display->loop, s->fd,
> > +	s->source = wl_event_loop_add_fd(display->loop, sock_fd,
> >  					 WL_EVENT_READABLE,
> >  					 socket_data, display);
> >  	if (s->source == NULL) {
> >  		wl_log("failed to establish event source\n");
> > +		wl_socket_destroy(s);
> >  		return -1;
> >  	}
> >  
> > +	/* Reuse the existing fd */
> > +	s->fd = sock_fd;
> > +
> >  	wl_list_insert(display->socket_list.prev, &s->link);
> >  
> >  	return 0;
> > 
> 
> _______________________________________________
> 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