Navigation Menu

Skip to content

Commit

Permalink
Fixed bug 3474 - IMG_tif leaks memory on errors
Browse files Browse the repository at this point in the history
Daniel

TIFFClose() is not called if TIFFReadRGBAImage() fails.
  • Loading branch information
slouken committed Nov 1, 2016
1 parent 78606e0 commit 15f68ba
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions IMG_tif.c
Expand Up @@ -204,7 +204,7 @@ int IMG_isTIF(SDL_RWops* src)
SDL_Surface* IMG_LoadTIF_RW(SDL_RWops* src)
{
Sint64 start;
TIFF* tiff;
TIFF* tiff = NULL;
SDL_Surface* surface = NULL;
Uint32 img_width, img_height;
Uint32 Rmask, Gmask, Bmask, Amask;
Expand Down Expand Up @@ -263,9 +263,12 @@ SDL_Surface* IMG_LoadTIF_RW(SDL_RWops* src)

error:
SDL_RWseek(src, start, RW_SEEK_SET);
if ( surface ) {
if (surface) {
SDL_FreeSurface(surface);
}
if (tiff) {
lib.TIFFClose(tiff);
}
return NULL;
}

Expand Down

0 comments on commit 15f68ba

Please sign in to comment.