handle eof better for buffer GIF

Add the new eof handling to the memory reader.
This commit is contained in:
John Cupitt 2019-08-24 18:49:56 +01:00
parent 1ac96313cc
commit 6c525e144b

View File

@ -1263,14 +1263,17 @@ G_DEFINE_TYPE( VipsForeignLoadGifBuffer, vips_foreign_load_gif_buffer,
static int
vips_giflib_buffer_read( GifFileType *file, GifByteType *buf, int n )
{
VipsForeignLoadGifBuffer *buffer =
(VipsForeignLoadGifBuffer *) file->UserData;
VipsForeignLoadGif *gif = (VipsForeignLoadGif *) file->UserData;
VipsForeignLoadGifBuffer *buffer = (VipsForeignLoadGifBuffer *) gif;
size_t will_read = VIPS_MIN( n, buffer->bytes_to_go );
memcpy( buf, buffer->p, will_read );
buffer->p += will_read;
buffer->bytes_to_go -= will_read;
if( will_read == 0 )
gif->eof = TRUE;
return( will_read );
}