Without this, undrawn pixels in the first frame will have the pixel
values from the previously drawn frame.
memset(img->mask[0], 0, img->width * img->height);
} else {
/* Start over if we are backtracking. */
- if (img->currentframe > frame)
+ if (img->currentframe > frame) {
+ memset(img->mask[0], 0, img->width * img->height);
img->currentframe = -1;
+ }
/* We must have previous frame decoded to continue. */
if (frame > img->currentframe + 1) {