better feof() handling in gif load
Relaxing the read error rules made looping possible .. make sure we always stop explicitly on eof.
This commit is contained in:
parent
038409093f
commit
4691260540
@ -10,6 +10,7 @@
|
||||
- fix a problem with shinkv tail processing [angelmixu]
|
||||
- fix a read one byte beyond buffer bug in jpegload
|
||||
- make GIF parsing less strict
|
||||
- better feof() handling in GIF load
|
||||
- clip coding and interpretation on vips image read
|
||||
|
||||
24/5/19 started 8.8.1
|
||||
|
@ -191,7 +191,6 @@ typedef struct _VipsForeignLoadGif {
|
||||
/* Params for DGifOpen(). Set by subclasses, called by base class in
|
||||
* _open().
|
||||
*/
|
||||
void *userPtr;
|
||||
InputFunc read_func;
|
||||
|
||||
} VipsForeignLoadGif;
|
||||
@ -1052,13 +1051,13 @@ vips_foreign_load_gif_open( VipsForeignLoadGif *gif )
|
||||
{
|
||||
int error;
|
||||
|
||||
if( !(gif->file = DGifOpen( gif->userPtr, gif->read_func, &error )) ) {
|
||||
if( !(gif->file = DGifOpen( gif, gif->read_func, &error )) ) {
|
||||
vips_foreign_load_gif_error_vips( gif, error );
|
||||
return( -1 );
|
||||
}
|
||||
}
|
||||
#else
|
||||
if( !(gif->file = DGifOpen( gif->userPtr, gif->read_func )) ) {
|
||||
if( !(gif->file = DGifOpen( gif, gif->read_func )) ) {
|
||||
vips_foreign_load_gif_error_vips( gif, GifLastError() );
|
||||
return( -1 );
|
||||
}
|
||||
@ -1161,11 +1160,15 @@ vips_foreign_load_gif_file_dispose( GObject *gobject )
|
||||
* across DLL boundaries on Windows.
|
||||
*/
|
||||
static int
|
||||
vips_giflib_file_read( GifFileType *file, GifByteType *buffer, int n )
|
||||
vips_giflib_file_read( GifFileType *gfile, GifByteType *buffer, int n )
|
||||
{
|
||||
FILE *fp = (FILE *) file->UserData;
|
||||
VipsForeignLoadGif *gif = (VipsForeignLoadGif *) gfile->UserData;
|
||||
VipsForeignLoadGifFile *file = (VipsForeignLoadGifFile *) gif;
|
||||
|
||||
return( (int) fread( (void *) buffer, 1, n, fp ) );
|
||||
if( feof( file->fp ) )
|
||||
gif->eof = TRUE;
|
||||
|
||||
return( (int) fread( (void *) buffer, 1, n, file->fp ) );
|
||||
}
|
||||
|
||||
static int
|
||||
@ -1185,7 +1188,6 @@ vips_foreign_load_gif_file_open( VipsForeignLoadGif *gif )
|
||||
rewind( file->fp );
|
||||
|
||||
vips_foreign_load_gif_close( gif );
|
||||
gif->userPtr = file->fp;
|
||||
gif->read_func = vips_giflib_file_read;
|
||||
|
||||
return( VIPS_FOREIGN_LOAD_GIF_CLASS(
|
||||
@ -1279,7 +1281,6 @@ vips_foreign_load_gif_buffer_open( VipsForeignLoadGif *gif )
|
||||
vips_foreign_load_gif_close( gif );
|
||||
buffer->p = buffer->buf->data;
|
||||
buffer->bytes_to_go = buffer->buf->length;
|
||||
gif->userPtr = gif;
|
||||
gif->read_func = vips_giflib_buffer_read;;
|
||||
|
||||
return( VIPS_FOREIGN_LOAD_GIF_CLASS(
|
||||
|
Loading…
Reference in New Issue
Block a user