Skip to content

Commit

Permalink
sdl: Move use of surface pointer below check for whether it is NULL
Browse files Browse the repository at this point in the history
In commit 2ab858c 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 <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Message-id: [email protected]
Signed-off-by: Gerd Hoffmann <[email protected]>
  • Loading branch information
pm215 authored and kraxel committed May 18, 2018
1 parent 68898bc commit e8dcb8a
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions ui/sdl2-2d.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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;
Expand Down

0 comments on commit e8dcb8a

Please sign in to comment.