Skip to content

Commit cfbedec

Browse files
committed
fix: SDL_LoadGIF() check for palette not null
fixes #48
1 parent 2270d8f commit cfbedec

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

ngiflibSDL.c

+7-4
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,14 @@ SDL_Surface * SDL_LoadGIF(const char * file)
8787
{
8888
SDL_SetColorKey(surface, SDL_SRCCOLORKEY, gif->cur_img->gce.transparent_color);
8989
}
90-
for(i=0; i<gif->ncolors; i++)
90+
if (gif->palette != NULL)
9191
{
92-
surface->format->palette->colors[i].r = gif->palette[i].r;
93-
surface->format->palette->colors[i].g = gif->palette[i].g;
94-
surface->format->palette->colors[i].b = gif->palette[i].b;
92+
for(i=0; i<gif->ncolors; i++)
93+
{
94+
surface->format->palette->colors[i].r = gif->palette[i].r;
95+
surface->format->palette->colors[i].g = gif->palette[i].g;
96+
surface->format->palette->colors[i].b = gif->palette[i].b;
97+
}
9598
}
9699
if(gif->width > 0 && gif->height > 0)
97100
{

0 commit comments

Comments
 (0)