@@ -189,19 +189,23 @@ struct ngiflibSDL_animation * SDL_LoadAnimatedGif(const char * file)
189
189
current_palette = gif -> palette ;
190
190
current_palette_size = gif -> ncolors ;
191
191
}
192
- for (i = 0 ; i < current_palette_size ; i ++ ) {
193
- surface -> format -> palette -> colors [i ].r = current_palette [i ].r ;
194
- surface -> format -> palette -> colors [i ].g = current_palette [i ].g ;
195
- surface -> format -> palette -> colors [i ].b = current_palette [i ].b ;
196
- //printf("#%02x%02x%02x ", current_palette[i].r, current_palette[i].g, current_palette[i].b);
197
- }
198
- for (; i < gif -> ncolors ; i ++ ) {
199
- surface -> format -> palette -> colors [i ].r = gif -> palette [i ].r ;
200
- surface -> format -> palette -> colors [i ].g = gif -> palette [i ].g ;
201
- surface -> format -> palette -> colors [i ].b = gif -> palette [i ].b ;
202
- //printf("#%02x%02x%02x ", gif->palette[i].r, gif->palette[i].g, gif->palette[i].b);
192
+ if (current_palette != NULL ) {
193
+ for (i = 0 ; i < current_palette_size ; i ++ ) {
194
+ surface -> format -> palette -> colors [i ].r = current_palette [i ].r ;
195
+ surface -> format -> palette -> colors [i ].g = current_palette [i ].g ;
196
+ surface -> format -> palette -> colors [i ].b = current_palette [i ].b ;
197
+ //printf("#%02x%02x%02x ", current_palette[i].r, current_palette[i].g, current_palette[i].b);
198
+ }
199
+ for (; i < gif -> ncolors ; i ++ ) {
200
+ surface -> format -> palette -> colors [i ].r = gif -> palette [i ].r ;
201
+ surface -> format -> palette -> colors [i ].g = gif -> palette [i ].g ;
202
+ surface -> format -> palette -> colors [i ].b = gif -> palette [i ].b ;
203
+ //printf("#%02x%02x%02x ", gif->palette[i].r, gif->palette[i].g, gif->palette[i].b);
204
+ }
205
+ //printf("\n");
206
+ } else {
207
+ fprintf (stderr , "no palette in GIF\n" );
203
208
}
204
- printf ("\n" );
205
209
psrc = p ; pdst = surface -> pixels ;
206
210
for (i = 0 ; i < gif -> height ; i ++ ) {
207
211
ngiflib_memcpy (pdst , psrc , gif -> width );
0 commit comments