From b443e824a2598ed98ea6be8fc7155d180313c307 Mon Sep 17 00:00:00 2001 From: Ynse Hoornenborg Date: Tue, 4 Jan 2022 21:51:25 +0100 Subject: [PATCH] Gif: Check on frame count before writing repeat count --- src/ImageSharp/Formats/Gif/GifEncoderCore.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/ImageSharp/Formats/Gif/GifEncoderCore.cs b/src/ImageSharp/Formats/Gif/GifEncoderCore.cs index c359653cbc..3f51fa6390 100644 --- a/src/ImageSharp/Formats/Gif/GifEncoderCore.cs +++ b/src/ImageSharp/Formats/Gif/GifEncoderCore.cs @@ -123,7 +123,7 @@ namespace SixLabors.ImageSharp.Formats.Gif this.WriteComments(gifMetadata, stream); // Write application extensions. - this.WriteApplicationExtensions(stream, gifMetadata.RepeatCount, metadata.XmpProfile); + this.WriteApplicationExtensions(stream, image.Frames.Count, gifMetadata.RepeatCount, metadata.XmpProfile); if (useGlobalTable) { @@ -324,9 +324,10 @@ namespace SixLabors.ImageSharp.Formats.Gif /// Writes the application extension to the stream. /// /// The stream to write to. + /// The frame count fo this image. /// The animated image repeat count. /// The XMP metadata profile. Null if profile is not to be written. - private void WriteApplicationExtensions(Stream stream, ushort repeatCount, XmpProfile xmpProfile) + private void WriteApplicationExtensions(Stream stream, int frameCount, ushort repeatCount, XmpProfile xmpProfile) { // Application Extension: Loop repeat count. if (repeatCount != 1)