Skip to content

Commit

Permalink
Fixed bug 1831 - Memory leak issue in SDL_image-1.2.12/IMG_xpm.c file
Browse files Browse the repository at this point in the history
Nitz

In this code hash memory is dynamically allocated, but its getting leak at 2 points.
  • Loading branch information
slouken committed May 22, 2013
1 parent ddcb8dc commit 715e4ca
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion IMG_xpm.c
Expand Up @@ -118,12 +118,15 @@ static struct color_hash *create_colorhash(int maxnum)
bytes = hash->size * sizeof(struct hash_entry **);
hash->entries = NULL; /* in case malloc fails */
hash->table = (struct hash_entry **)SDL_malloc(bytes);
if(!hash->table)
if(!hash->table) {
SDL_free(hash);
return NULL;
}
memset(hash->table, 0, bytes);
hash->entries = (struct hash_entry *)SDL_malloc(maxnum * sizeof(struct hash_entry));
if(!hash->entries) {
SDL_free(hash->table);
SDL_free(hash);
return NULL;
}
hash->next_free = hash->entries;
Expand Down

0 comments on commit 715e4ca

Please sign in to comment.