sdl: Move use of surface pointer below check for whether it is NULL
PATCH 1/1 sdl: Move use of surface pointer below check for whether it is NULL
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.
--- ui/sdl2-2d.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
ui/sdl2-2d.c +3 -3
@@ -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;
Signature · 1 line
2.17.0
Quoted 6 lines · Peter Maydell
In commit
2ab858c6c38ee1we added a use of the 'surf' variable insdl2_2d_update()that was unfortunately placed above the early-exit-if-NULL check. Move it to where it ought to be.Fixes Coverity CID 1390598Signed-off-by Peter Maydell <[email protected]>
Quoted 29 lines
--- ui/sdl2-2d.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)ui/sdl2-2d.c +3
-3@@ -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;
Quoted 3 lines · Peter Maydell
In commit
2ab858c6c38ee1we added a use of the 'surf' variable insdl2_2d_update()that was unfortunately placed above the early-exit-if-NULL check. Move it to where it ought to be.
Added to ui patch queue.
thanks,
Gerd
Please excuse me and thank you very much for the fix!
2018-05-18 10:04 GMT+03:00 Gerd Hoffmann <[email protected]>:
Quoted 11 lines · Peter Maydell
Quoted 3 lines
In commit
2ab858c6c38ee1we added a use of the 'surf' variable insdl2_2d_update()that was unfortunately placed above the early-exit-if-NULL check. Move it to where it ought to be.Added to ui patch queue.
thanks,
Gerd
Signature · 1 line
Anatoly <[email protected]>