[PATCH weston 02/11] desktop-shell: Return NULL when no outputs are present

Armin Krezović krezovic.armin at gmail.com
Wed Jun 22 09:25:14 UTC 2016


On 20.06.2016 12:40, Pekka Paalanen wrote:
> On Sun, 19 Jun 2016 11:08:33 +0200
> Quentin Glidic <sardemff7+wayland at sardemff7.net> wrote:
> 
>> On 18/06/2016 19:15, Armin Krezović wrote:
>>> Currently, get_default_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>
>>> ---
>>>  desktop-shell/shell.c | 3 +++
>>>  1 file changed, 3 insertions(+)
>>>
>>> diff --git a/desktop-shell/shell.c b/desktop-shell/shell.c
>>> index 79cf8dd..c48d41a 100644
>>> --- a/desktop-shell/shell.c
>>> +++ b/desktop-shell/shell.c
>>> @@ -688,6 +688,9 @@ shell_configuration(struct desktop_shell *shell)
>>>  struct weston_output *
>>>  get_default_output(struct weston_compositor *compositor)
>>>  {
>>> +	if (wl_list_empty(&compositor->output_list))
>>> +		return NULL;
>>> +
>>>  	return container_of(compositor->output_list.next,
>>>  			    struct weston_output, link);
>>>  }
>>>  
>>
>> Good.
>> Reviewed-by: Quentin Glidic <sardemff7+git at sardemff7.net>
> 
> Reviewed-by: Pekka Paalanen <pekka.paalanen at collabora.co.uk>
> 
> 
> Thanks,
> pq
> 

Thanks for the review!

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 855 bytes
Desc: OpenPGP digital signature
URL: <https://lists.freedesktop.org/archives/wayland-devel/attachments/20160622/526e6320/attachment.sig>


More information about the wayland-devel mailing list