[PATCH weston 04/11] compositor: Avoid NULL pointer dereference

Quentin Glidic sardemff7+wayland at sardemff7.net
Sun Jun 19 09:10:03 UTC 2016


On 18/06/2016 19:15, Armin Krezović wrote:
> When there are no outputs present, an output pointer
> can be NULL. Dereferencing such pointer will result
> in a crash.
>
> Signed-off-by: Armin Krezović <krezovic.armin at gmail.com>
> ---
>  src/compositor.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/src/compositor.c b/src/compositor.c
> index 37d94ec..d246046 100644
> --- a/src/compositor.c
> +++ b/src/compositor.c
> @@ -191,6 +191,9 @@ weston_output_mode_switch_to_native(struct weston_output *output)
>  	int ret;
>  	int mode_changed = 0, scale_changed = 0;
>
> +	if (!output)

Maybe do we want an assert here, and make sure the callers are properly 
checking for NULL beforehand?


> +		return -1;
> +
>  	if (!output->switch_mode)
>  		return -1;
>
>


-- 

Quentin “Sardem FF7” Glidic


More information about the wayland-devel mailing list