Browse Source

Fixed bug 2957 - De-reference rz_src without NULL check in SDLgfx_rotateSurface function

Nitz

In function SDLgfx_rotateSurface:

rz_dst =
            SDL_CreateRGBSurface(SDL_SWSURFACE, dstwidth, dstheight + GUARD_ROWS,
            rz_src->format->Rmask, rz_src->format->Gmask,
            rz_src->format->Bmask, rz_src->format->Amask);

Here rz_src get De-referenced without NULL check, which is risky.
Sam Lantinga 9 years ago
parent
commit
bf076c22ad
1 changed files with 3 additions and 2 deletions
  1. 3 2
      src/render/software/SDL_rotate.c

+ 3 - 2
src/render/software/SDL_rotate.c

@@ -378,10 +378,12 @@ SDLgfx_rotateSurface(SDL_Surface * src, double angle, int centerx, int centery,
 #endif
 #endif
         );
         );
         rz_src = SDL_ConvertSurfaceFormat(src, format, src->flags);
         rz_src = SDL_ConvertSurfaceFormat(src, format, src->flags);
+        if (rz_src == NULL) {
+            return NULL;
+        }
         is32bit = 1;
         is32bit = 1;
     }
     }
 
 
-
     /* Determine target size */
     /* Determine target size */
     /* _rotozoomSurfaceSizeTrig(rz_src->w, rz_src->h, angle, &dstwidth, &dstheight, &cangle, &sangle); */
     /* _rotozoomSurfaceSizeTrig(rz_src->w, rz_src->h, angle, &dstwidth, &dstheight, &cangle, &sangle); */
 
 
@@ -394,7 +396,6 @@ SDLgfx_rotateSurface(SDL_Surface * src, double angle, int centerx, int centery,
     /*
     /*
     * Alloc space to completely contain the rotated surface
     * Alloc space to completely contain the rotated surface
     */
     */
-    rz_dst = NULL;
     if (is32bit) {
     if (is32bit) {
         /*
         /*
         * Target surface is 32bit with source RGBA/ABGR ordering
         * Target surface is 32bit with source RGBA/ABGR ordering