Menu

#16 `rotateSurface90Degrees` returns a locked surface

v1.0 (example)
open
nobody
None
5
2023-12-11
2023-12-07
No

I just spent several hours debugging an issue with SDL, and finally discovered a bug in SDL_gfx: the function rotateSurface90Degrees() has a copy&paste error in its implementation, which causes it to lock the returned surface twice:

    if (SDL_MUSTLOCK(dst)) {
        SDL_LockSurface(dst);
    }
    if (SDL_MUSTLOCK(dst)) {
        SDL_LockSurface(dst);
    }

(you can find this code here). Indeed, the author wanted to lock dst only once, and then to lock src. The end of the function has the respective calls to SDL_UnlockSurface().

Discussion

  • ferzkopp

    ferzkopp - 2023-12-08

    Thanks for the report.

     
    • Dave Murphy

      Dave Murphy - 2023-12-09

      Is this the canonical source for SDL_gfx? I found some copies on github as well.

      Mainly asking because we're using this for wii & gamecube & Alberto reported this at https://github.com/devkitPro/pacman-packages/issues/331 as well. I'll patch it for us for now but would obvious prefer to be using upstream if possible.

       
  • Dave Murphy

    Dave Murphy - 2023-12-09

    Patch, if it helps.

    --- SDL_gfx-2.0.25/SDL_rotozoom.c~  2023-12-09 21:24:48.317633493 +0000
    +++ SDL_gfx-2.0.25/SDL_rotozoom.c   2023-12-09 21:23:31.163959705 +0000
    @@ -841,8 +841,8 @@
        if (SDL_MUSTLOCK(dst)) {
            SDL_LockSurface(dst);
        }
    -   if (SDL_MUSTLOCK(dst)) {
    -       SDL_LockSurface(dst);
    +   if (SDL_MUSTLOCK(src)) {
    +       SDL_LockSurface(src);
        }
    
        /* Calculate int-per-row */
    
     
  • ferzkopp

    ferzkopp - 2023-12-10

    Thanks for the patch. It may take me some time to get around to make a new release as this code is rather old.

     
  • ferzkopp

    ferzkopp - 2023-12-11

    Made a 2.0.27 release with this fix. Please check if that works for you.

     

    Last edit: ferzkopp 2023-12-11

Log in to post a comment.

MongoDB Logo MongoDB