#8 ZoomSurface: Memory leak at error and miss error checking

closed-fixed
nobody
None
5
2011-12-04
2011-09-13
RodolfoRG
No

On file SDL_rotozoom.c, the function
SDL_Surface *zoomSurface(SDL_Surface * src, double zoomx, double zoomy, int smooth)

When rz_src surface need to be created, it doesn't check if creation was successfull.
rz_src =

SDL_CreateRGBSurface(SDL_SWSURFACE, src->w, src->h, 32,

#if SDL_BYTEORDER == SDL_LIL_ENDIAN

0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000

#else

0xff000000, 0x00ff0000, 0x0000ff00, 0x000000ff

#endif

);
/* Add this */
if (rz_src == NULL)
{
fprintf(stderr, "Error detected by Rodolfo\n");
return NULL;
}
/* End of patch */

If rz_dst cannot be allocate, it doesn't free rz_src if allocated.

if (rz_dst == NULL)
/* Patch beginning*/
{
if (rz_src != src)
SDL_FreeSurface(rz_src);

return NULL;
}

/* End of patch */

Discussion

  • ferzkopp

    ferzkopp - 2011-12-04
    • status: open --> closed-fixed
     
  • ferzkopp

    ferzkopp - 2011-12-04

    Thanks!

     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks