[PATCH weston 03/11] toytoolkit: Return NULL when no outputs are present
Pekka Paalanen
ppaalanen at gmail.com
Mon Jun 20 13:23:53 UTC 2016
On Sun, 19 Jun 2016 11:08:50 +0200
Quentin Glidic <sardemff7+wayland at sardemff7.net> wrote:
> On 18/06/2016 19:15, Armin Krezović wrote:
> > Currently, display_get_output returns a first member
> > of the linked list, which can never be NULL.
> >
> > This is problematic, as the function would return a
> > dangling pointer and NULL pointer checks wouldn't
> > work where needed and some of the invalid members
> > would get accessed that way, resulting in a crash.
> >
> > Signed-off-by: Armin Krezović <krezovic.armin at gmail.com>
> > ---
> > clients/window.c | 3 +++
> > 1 file changed, 3 insertions(+)
> >
> > diff --git a/clients/window.c b/clients/window.c
> > index b5b598f..4de73ed 100644
> > --- a/clients/window.c
> > +++ b/clients/window.c
> > @@ -5845,6 +5845,9 @@ display_get_cairo_device(struct display *display)
> > struct output *
> > display_get_output(struct display *display)
> > {
> > + if (wl_list_empty(&display->output_list))
> > + return NULL;
> > +
> > return container_of(display->output_list.next, struct output, link);
> > }
> >
> >
>
> Good.
> Reviewed-by: Quentin Glidic <sardemff7+git at sardemff7.net>
Reviewed-by: Pekka Paalanen <pekka.paalanen at collabora.co.uk>
Thanks,
pq
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 811 bytes
Desc: OpenPGP digital signature
URL: <https://lists.freedesktop.org/archives/wayland-devel/attachments/20160620/8b88068d/attachment.sig>
More information about the wayland-devel
mailing list