Skip to content

Commit

Permalink
Fixed bug 2010 - Memory leaks in do_layer_surface function in IMG_xcf…
Browse files Browse the repository at this point in the history
….c file

Nitz

In static int do_layer_surface (SDL_Surface * surface, SDL_RWops * src, xcf_header * head, xcf_layer * layer, load_tile_type load_tile)

hierarchy, level and tile pointers are getting leak at default cases of switch statement.
  • Loading branch information
slouken committed Aug 7, 2013
1 parent 601fe27 commit 1c108f1
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion IMG_xcf.c
Expand Up @@ -289,7 +289,7 @@ static void free_xcf_header (xcf_header * h) {
if (h->cm_num)
SDL_free (h->cm_map);
if (h->layer_file_offsets)
SDL_free (h->layer_file_offsets);
SDL_free (h->layer_file_offsets);
SDL_free (h);
}

Expand Down Expand Up @@ -625,6 +625,15 @@ static int do_layer_surface (SDL_Surface * surface, SDL_RWops * src, xcf_header
break;
default:
fprintf (stderr, "Unknown Gimp image type (%d)\n", head->image_type);
if (hierarchy)
{
if (hierarchy->level_file_offsets)
SDL_free(hierarchy->level_file_offsets);

free_xcf_hierarchy(hierarchy);
}
if (level)
free_xcf_level (level);
return 1;
}
break;
Expand All @@ -650,6 +659,12 @@ static int do_layer_surface (SDL_Surface * surface, SDL_RWops * src, xcf_header
break;
default:
fprintf (stderr, "Unknown Gimp image type (%d)\n", head->image_type);
if (tile)
free_xcf_tile (tile);
if (level)
free_xcf_level (level);
if (hierarchy)
free_xcf_hierarchy (hierarchy);
return 1;
}
break;
Expand Down

0 comments on commit 1c108f1

Please sign in to comment.