From bf522eeffc5aa84a275b1d53e24d0daace59fa3e Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Sun, 7 Mar 2021 14:37:33 +0000 Subject: [PATCH] fix libnsgif restore/record ordering --- libvips/foreign/libnsgif/libnsgif.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/libvips/foreign/libnsgif/libnsgif.c b/libvips/foreign/libnsgif/libnsgif.c index d8d5df19..a97be035 100644 --- a/libvips/foreign/libnsgif/libnsgif.c +++ b/libvips/foreign/libnsgif/libnsgif.c @@ -704,11 +704,6 @@ gif_internal_decode_frame(gif_animation *gif, return GIF_OK; } - if (gif->frames[frame].disposal_method == GIF_FRAME_RESTORE) { - /* Store the previous frame for later restoration */ - gif__record_previous_frame(gif); - } - /* Get the start of our frame data and the end of the GIF data */ gif_data = gif->gif_data + gif->frames[frame].frame_pointer; gif_end = gif->gif_data + gif->buffer_size; @@ -897,6 +892,12 @@ gif_internal_decode_frame(gif_animation *gif, gif->width * gif->height * sizeof(int)); } } + + if (gif->frames[frame].disposal_method == GIF_FRAME_RESTORE) { + /* Store the previous frame for later restoration */ + gif__record_previous_frame(gif); + } + gif->decoded_frame = frame; gif->buffer_position = (gif_data - gif->gif_data) + 1;