qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH] sdl: Move use of surface pointer below check fo


From: Philippe Mathieu-Daudé
Subject: Re: [Qemu-devel] [PATCH] sdl: Move use of surface pointer below check for whether it is NULL
Date: Tue, 15 May 2018 17:51:41 -0300
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0

On 05/15/2018 03:58 PM, Peter Maydell wrote:
> In commit 2ab858c6c38ee1 we added a use of the 'surf' variable
> in sdl2_2d_update() that was unfortunately placed above the
> early-exit-if-NULL check. Move it to where it ought to be.
> 
> Fixes: Coverity CID 1390598
> Signed-off-by: Peter Maydell <address@hidden>

Reviewed-by: Philippe Mathieu-Daudé <address@hidden>

> ---
>  ui/sdl2-2d.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/ui/sdl2-2d.c b/ui/sdl2-2d.c
> index 1f34817bae..85484407be 100644
> --- a/ui/sdl2-2d.c
> +++ b/ui/sdl2-2d.c
> @@ -36,9 +36,7 @@ void sdl2_2d_update(DisplayChangeListener *dcl,
>      struct sdl2_console *scon = container_of(dcl, struct sdl2_console, dcl);
>      DisplaySurface *surf = qemu_console_surface(dcl->con);
>      SDL_Rect rect;
> -    size_t surface_data_offset = surface_bytes_per_pixel(surf) * x +
> -                                 surface_stride(surf) * y;
> -
> +    size_t surface_data_offset;
>      assert(!scon->opengl);
>  
>      if (!surf) {
> @@ -48,6 +46,8 @@ void sdl2_2d_update(DisplayChangeListener *dcl,
>          return;
>      }
>  
> +    surface_data_offset = surface_bytes_per_pixel(surf) * x +
> +                          surface_stride(surf) * y;
>      rect.x = x;
>      rect.y = y;
>      rect.w = w;
> 



reply via email to

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