fix: do not try to use "undefined" delay

Expression could be truthy even when no `delay` was provided by user.

Now, the `delay_length` is 0 by default to avoid this situation.
This commit is contained in:
Tomáš Szabo 2019-12-18 15:23:57 +01:00
parent 45015b002a
commit 057459fd7d
No known key found for this signature in database
GPG Key ID: 96F1E84929851783

View File

@ -330,6 +330,7 @@ write_webp_anim( VipsWebPWrite *write, VipsImage *image, int page_height )
/* New images have an array of ints instead.
*/
delay_length = 0;
if( vips_image_get_typeof( image, "delay" ) &&
vips_image_get_array_int( image, "delay",
&delay, &delay_length ) )
@ -363,8 +364,7 @@ write_webp_anim( VipsWebPWrite *write, VipsImage *image, int page_height )
WebPPictureFree( &pic );
page_index = top / page_height;
if( delay &&
page_index < delay_length )
if( page_index < delay_length )
timestamp_ms += delay[page_index];
else
timestamp_ms += gif_delay * 10;