qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] ui/gtk: fix NULL pointer dereference


From: Akihiko Odaki
Subject: Re: [PATCH] ui/gtk: fix NULL pointer dereference
Date: Mon, 8 Mar 2021 12:45:24 +0900

2021年3月8日(月) 4:57 Christian Schoenebeck <qemu_oss@crudebyte.com>:
>
> DisplaySurface pointer passed to gd_switch() can be NULL, so check this
> before trying to dereference it.
>
> Fixes: c821a58ee7 ("ui/console: Pass placeholder surface to display")
> Reported-by: Coverity (CID 1448421)
> Signed-off-by: Christian Schoenebeck <qemu_oss@crudebyte.com>
> ---
>  ui/gtk.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/ui/gtk.c b/ui/gtk.c
> index 3edaf041de..a27b27d004 100644
> --- a/ui/gtk.c
> +++ b/ui/gtk.c
> @@ -567,7 +567,7 @@ static void gd_switch(DisplayChangeListener *dcl,
>      }
>      vc->gfx.ds = surface;
>
> -    if (surface->format == PIXMAN_x8r8g8b8) {
> +    if (surface && surface->format == PIXMAN_x8r8g8b8) {
>          /*
>           * PIXMAN_x8r8g8b8 == CAIRO_FORMAT_RGB24
>           *
> @@ -580,7 +580,7 @@ static void gd_switch(DisplayChangeListener *dcl,
>               surface_width(surface),
>               surface_height(surface),
>               surface_stride(surface));
> -    } else {
> +    } else if (surface) {
>          /* Must convert surface, use pixman to do it. */
>          vc->gfx.convert = pixman_image_create_bits(PIXMAN_x8r8g8b8,
>                                                     surface_width(surface),
> --
> 2.20.1
>

When will the DisplaySurface pointer passed to gd_switch() be NULL?
Also, it affects other displays so it should be fixed in ui/console.c,
or fix all relevant displays.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]