toytoolkit: Return NULL when no outputs are present
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. Reviewed-by: Quentin Glidic <sardemff7+git@sardemff7.net> Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk> Signed-off-by: Armin Krezović <krezovic.armin@gmail.com>
This commit is contained in:
parent
10b0618c07
commit
7dda25b2d5
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue