fix a crash in gifload with a missing colormap

it seems gifs can have a missing colormap, who knew

thanks Kleis

see https://github.com/jcupitt/libvips/issues/773
This commit is contained in:
John Cupitt 2017-10-15 22:35:52 +01:00
parent 68ed42e2fa
commit 53119250cc

View File

@ -13,6 +13,8 @@
* - better transparency detection, thanks diegocsandrim
* 25/11/16
* - support @n, page-height
* 5/10/17
* - colormap can be missing thanks Kleis
*/
/*
@ -367,17 +369,22 @@ vips_foreign_load_gif_render_line( VipsForeignLoadGif *gif,
for( x = 0; x < width; x++ ) {
VipsPel v = p[x];
if( v >= map->ColorCount ) {
g_warning( "%s", _( "pixel value out of range" ) );
continue;
}
if( v != gif->transparency ) {
if( map &&
v < map->ColorCount &&
v != gif->transparency ) {
q[0] = map->Colors[v].Red;
q[1] = map->Colors[v].Green;
q[2] = map->Colors[v].Blue;
q[3] = 255;
}
else if( v != gif->transparency ) {
/* If there's no map, just save the index.
*/
q[0] = v;
q[1] = v;
q[2] = v;
q[3] = 255;
}
else {
q[0] = 0;
q[1] = 0;
@ -414,7 +421,8 @@ vips_foreign_load_gif_render( VipsForeignLoadGif *gif, VipsImage *out )
/* Check if we have a non-greyscale colourmap for this frame.
*/
if( !gif->has_colour ) {
if( !gif->has_colour &&
map ) {
int i;
for( i = 0; i < map->ColorCount; i++ )