Skip to content

Backport V2 - GIF: Check for end of stream when reading comments. #2971

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jul 30, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,13 @@
<PropertyGroup Condition="$(Configuration.StartsWith('Release')) == true">
<Optimize>true</Optimize>
</PropertyGroup>

<!-- Required restore feeds. -->
<PropertyGroup>
<RestoreSources>
https://api.nuget.org/v3/index.json;
https://f.feedz.io/sixlabors/sixlabors/nuget/index.json;
https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-eng/nuget/v3/index.json;
</RestoreSources>
</PropertyGroup>
</Project>
5 changes: 5 additions & 0 deletions src/ImageSharp/Formats/Gif/GifDecoderCore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@
public IImageInfo Identify(BufferedReadStream stream, CancellationToken cancellationToken)
{
uint frameCount = 0;
ImageFrameMetadata? previousFrame = null;

Check warning on line 194 in src/ImageSharp/Formats/Gif/GifDecoderCore.cs

View workflow job for this annotation

GitHub Actions / Build (ubuntu-latest, net5.0, -x64, false)

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 194 in src/ImageSharp/Formats/Gif/GifDecoderCore.cs

View workflow job for this annotation

GitHub Actions / Build (ubuntu-latest, net6.0, 6.0.x, true, -x64, false)

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 194 in src/ImageSharp/Formats/Gif/GifDecoderCore.cs

View workflow job for this annotation

GitHub Actions / Build (macos-13, net5.0, -x64, false)

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 194 in src/ImageSharp/Formats/Gif/GifDecoderCore.cs

View workflow job for this annotation

GitHub Actions / Build (ubuntu-latest, netcoreapp3.1, -x64, false)

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 194 in src/ImageSharp/Formats/Gif/GifDecoderCore.cs

View workflow job for this annotation

GitHub Actions / Build (windows-latest, netcoreapp2.1, -x64, false)

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 194 in src/ImageSharp/Formats/Gif/GifDecoderCore.cs

View workflow job for this annotation

GitHub Actions / Build (windows-latest, net6.0, 6.0.x, true, -x64, false)

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 194 in src/ImageSharp/Formats/Gif/GifDecoderCore.cs

View workflow job for this annotation

GitHub Actions / Build (windows-latest, netcoreapp3.1, -x64, false)

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 194 in src/ImageSharp/Formats/Gif/GifDecoderCore.cs

View workflow job for this annotation

GitHub Actions / Build (macos-13, netcoreapp3.1, -x64, false)

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 194 in src/ImageSharp/Formats/Gif/GifDecoderCore.cs

View workflow job for this annotation

GitHub Actions / Build (windows-latest, net5.0, -x64, false)

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 194 in src/ImageSharp/Formats/Gif/GifDecoderCore.cs

View workflow job for this annotation

GitHub Actions / Build (windows-latest, net472, -x64, false)

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 194 in src/ImageSharp/Formats/Gif/GifDecoderCore.cs

View workflow job for this annotation

GitHub Actions / Build (windows-latest, net472, -x86, false)

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 194 in src/ImageSharp/Formats/Gif/GifDecoderCore.cs

View workflow job for this annotation

GitHub Actions / Build (macos-13, net6.0, 6.0.x, true, -x64, false)

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.
List<ImageFrameMetadata> framesMetadata = new();
try
{
Expand Down Expand Up @@ -402,6 +402,11 @@
GifThrowHelper.ThrowInvalidImageContentException($"Gif comment length '{length}' exceeds max '{GifConstants.MaxCommentSubBlockLength}' of a comment data block");
}

if (length == -1)
{
GifThrowHelper.ThrowInvalidImageContentException("Unexpected end of stream while reading gif comment");
}

if (this.skipMetadata)
{
stream.Seek(length, SeekOrigin.Current);
Expand Down Expand Up @@ -429,7 +434,7 @@
/// <param name="stream">The <see cref="BufferedReadStream"/> containing image data.</param>
/// <param name="image">The image to decode the information to.</param>
/// <param name="previousFrame">The previous frame.</param>
private void ReadFrame<TPixel>(BufferedReadStream stream, ref Image<TPixel>? image, ref ImageFrame<TPixel>? previousFrame)

Check warning on line 437 in src/ImageSharp/Formats/Gif/GifDecoderCore.cs

View workflow job for this annotation

GitHub Actions / Build (ubuntu-latest, net5.0, -x64, false)

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 437 in src/ImageSharp/Formats/Gif/GifDecoderCore.cs

View workflow job for this annotation

GitHub Actions / Build (ubuntu-latest, net5.0, -x64, false)

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 437 in src/ImageSharp/Formats/Gif/GifDecoderCore.cs

View workflow job for this annotation

GitHub Actions / Build (ubuntu-latest, net6.0, 6.0.x, true, -x64, false)

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 437 in src/ImageSharp/Formats/Gif/GifDecoderCore.cs

View workflow job for this annotation

GitHub Actions / Build (ubuntu-latest, net6.0, 6.0.x, true, -x64, false)

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 437 in src/ImageSharp/Formats/Gif/GifDecoderCore.cs

View workflow job for this annotation

GitHub Actions / Build (macos-13, net5.0, -x64, false)

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 437 in src/ImageSharp/Formats/Gif/GifDecoderCore.cs

View workflow job for this annotation

GitHub Actions / Build (macos-13, net5.0, -x64, false)

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 437 in src/ImageSharp/Formats/Gif/GifDecoderCore.cs

View workflow job for this annotation

GitHub Actions / Build (ubuntu-latest, netcoreapp3.1, -x64, false)

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 437 in src/ImageSharp/Formats/Gif/GifDecoderCore.cs

View workflow job for this annotation

GitHub Actions / Build (ubuntu-latest, netcoreapp3.1, -x64, false)

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 437 in src/ImageSharp/Formats/Gif/GifDecoderCore.cs

View workflow job for this annotation

GitHub Actions / Build (windows-latest, netcoreapp2.1, -x64, false)

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 437 in src/ImageSharp/Formats/Gif/GifDecoderCore.cs

View workflow job for this annotation

GitHub Actions / Build (windows-latest, netcoreapp2.1, -x64, false)

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 437 in src/ImageSharp/Formats/Gif/GifDecoderCore.cs

View workflow job for this annotation

GitHub Actions / Build (windows-latest, net6.0, 6.0.x, true, -x64, false)

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 437 in src/ImageSharp/Formats/Gif/GifDecoderCore.cs

View workflow job for this annotation

GitHub Actions / Build (windows-latest, net6.0, 6.0.x, true, -x64, false)

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 437 in src/ImageSharp/Formats/Gif/GifDecoderCore.cs

View workflow job for this annotation

GitHub Actions / Build (windows-latest, netcoreapp3.1, -x64, false)

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 437 in src/ImageSharp/Formats/Gif/GifDecoderCore.cs

View workflow job for this annotation

GitHub Actions / Build (windows-latest, netcoreapp3.1, -x64, false)

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 437 in src/ImageSharp/Formats/Gif/GifDecoderCore.cs

View workflow job for this annotation

GitHub Actions / Build (macos-13, netcoreapp3.1, -x64, false)

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 437 in src/ImageSharp/Formats/Gif/GifDecoderCore.cs

View workflow job for this annotation

GitHub Actions / Build (macos-13, netcoreapp3.1, -x64, false)

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 437 in src/ImageSharp/Formats/Gif/GifDecoderCore.cs

View workflow job for this annotation

GitHub Actions / Build (windows-latest, net5.0, -x64, false)

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 437 in src/ImageSharp/Formats/Gif/GifDecoderCore.cs

View workflow job for this annotation

GitHub Actions / Build (windows-latest, net5.0, -x64, false)

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 437 in src/ImageSharp/Formats/Gif/GifDecoderCore.cs

View workflow job for this annotation

GitHub Actions / Build (windows-latest, net472, -x64, false)

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 437 in src/ImageSharp/Formats/Gif/GifDecoderCore.cs

View workflow job for this annotation

GitHub Actions / Build (windows-latest, net472, -x64, false)

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 437 in src/ImageSharp/Formats/Gif/GifDecoderCore.cs

View workflow job for this annotation

GitHub Actions / Build (windows-latest, net472, -x86, false)

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 437 in src/ImageSharp/Formats/Gif/GifDecoderCore.cs

View workflow job for this annotation

GitHub Actions / Build (windows-latest, net472, -x86, false)

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 437 in src/ImageSharp/Formats/Gif/GifDecoderCore.cs

View workflow job for this annotation

GitHub Actions / Build (macos-13, net6.0, 6.0.x, true, -x64, false)

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 437 in src/ImageSharp/Formats/Gif/GifDecoderCore.cs

View workflow job for this annotation

GitHub Actions / Build (macos-13, net6.0, 6.0.x, true, -x64, false)

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.
where TPixel : unmanaged, IPixel<TPixel>
{
this.ReadImageDescriptor(stream);
Expand Down Expand Up @@ -473,8 +478,8 @@
/// <param name="descriptor">The <see cref="GifImageDescriptor"/></param>
private void ReadFrameColors<TPixel>(
BufferedReadStream stream,
ref Image<TPixel>? image,

Check warning on line 481 in src/ImageSharp/Formats/Gif/GifDecoderCore.cs

View workflow job for this annotation

GitHub Actions / Build (ubuntu-latest, net5.0, -x64, false)

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 481 in src/ImageSharp/Formats/Gif/GifDecoderCore.cs

View workflow job for this annotation

GitHub Actions / Build (ubuntu-latest, net6.0, 6.0.x, true, -x64, false)

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 481 in src/ImageSharp/Formats/Gif/GifDecoderCore.cs

View workflow job for this annotation

GitHub Actions / Build (macos-13, net5.0, -x64, false)

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 481 in src/ImageSharp/Formats/Gif/GifDecoderCore.cs

View workflow job for this annotation

GitHub Actions / Build (ubuntu-latest, netcoreapp3.1, -x64, false)

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 481 in src/ImageSharp/Formats/Gif/GifDecoderCore.cs

View workflow job for this annotation

GitHub Actions / Build (windows-latest, netcoreapp2.1, -x64, false)

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 481 in src/ImageSharp/Formats/Gif/GifDecoderCore.cs

View workflow job for this annotation

GitHub Actions / Build (windows-latest, net6.0, 6.0.x, true, -x64, false)

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 481 in src/ImageSharp/Formats/Gif/GifDecoderCore.cs

View workflow job for this annotation

GitHub Actions / Build (windows-latest, netcoreapp3.1, -x64, false)

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 481 in src/ImageSharp/Formats/Gif/GifDecoderCore.cs

View workflow job for this annotation

GitHub Actions / Build (macos-13, netcoreapp3.1, -x64, false)

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 481 in src/ImageSharp/Formats/Gif/GifDecoderCore.cs

View workflow job for this annotation

GitHub Actions / Build (windows-latest, net5.0, -x64, false)

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 481 in src/ImageSharp/Formats/Gif/GifDecoderCore.cs

View workflow job for this annotation

GitHub Actions / Build (windows-latest, net472, -x64, false)

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 481 in src/ImageSharp/Formats/Gif/GifDecoderCore.cs

View workflow job for this annotation

GitHub Actions / Build (windows-latest, net472, -x86, false)

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 481 in src/ImageSharp/Formats/Gif/GifDecoderCore.cs

View workflow job for this annotation

GitHub Actions / Build (macos-13, net6.0, 6.0.x, true, -x64, false)

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.
ref ImageFrame<TPixel>? previousFrame,

Check warning on line 482 in src/ImageSharp/Formats/Gif/GifDecoderCore.cs

View workflow job for this annotation

GitHub Actions / Build (ubuntu-latest, net5.0, -x64, false)

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 482 in src/ImageSharp/Formats/Gif/GifDecoderCore.cs

View workflow job for this annotation

GitHub Actions / Build (ubuntu-latest, net6.0, 6.0.x, true, -x64, false)

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 482 in src/ImageSharp/Formats/Gif/GifDecoderCore.cs

View workflow job for this annotation

GitHub Actions / Build (macos-13, net5.0, -x64, false)

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 482 in src/ImageSharp/Formats/Gif/GifDecoderCore.cs

View workflow job for this annotation

GitHub Actions / Build (ubuntu-latest, netcoreapp3.1, -x64, false)

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 482 in src/ImageSharp/Formats/Gif/GifDecoderCore.cs

View workflow job for this annotation

GitHub Actions / Build (windows-latest, netcoreapp2.1, -x64, false)

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 482 in src/ImageSharp/Formats/Gif/GifDecoderCore.cs

View workflow job for this annotation

GitHub Actions / Build (windows-latest, net6.0, 6.0.x, true, -x64, false)

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 482 in src/ImageSharp/Formats/Gif/GifDecoderCore.cs

View workflow job for this annotation

GitHub Actions / Build (windows-latest, netcoreapp3.1, -x64, false)

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 482 in src/ImageSharp/Formats/Gif/GifDecoderCore.cs

View workflow job for this annotation

GitHub Actions / Build (macos-13, netcoreapp3.1, -x64, false)

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 482 in src/ImageSharp/Formats/Gif/GifDecoderCore.cs

View workflow job for this annotation

GitHub Actions / Build (windows-latest, net5.0, -x64, false)

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 482 in src/ImageSharp/Formats/Gif/GifDecoderCore.cs

View workflow job for this annotation

GitHub Actions / Build (windows-latest, net472, -x64, false)

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 482 in src/ImageSharp/Formats/Gif/GifDecoderCore.cs

View workflow job for this annotation

GitHub Actions / Build (windows-latest, net472, -x86, false)

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 482 in src/ImageSharp/Formats/Gif/GifDecoderCore.cs

View workflow job for this annotation

GitHub Actions / Build (macos-13, net6.0, 6.0.x, true, -x64, false)

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.
ReadOnlySpan<Rgb24> colorTable,
in GifImageDescriptor descriptor)
where TPixel : unmanaged, IPixel<TPixel>
Expand All @@ -483,8 +488,8 @@
int imageHeight = this.logicalScreenDescriptor.Height;
bool transFlag = this.graphicsControlExtension.TransparencyFlag;

ImageFrame<TPixel>? prevFrame = null;

Check warning on line 491 in src/ImageSharp/Formats/Gif/GifDecoderCore.cs

View workflow job for this annotation

GitHub Actions / Build (ubuntu-latest, net5.0, -x64, false)

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 491 in src/ImageSharp/Formats/Gif/GifDecoderCore.cs

View workflow job for this annotation

GitHub Actions / Build (ubuntu-latest, net6.0, 6.0.x, true, -x64, false)

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 491 in src/ImageSharp/Formats/Gif/GifDecoderCore.cs

View workflow job for this annotation

GitHub Actions / Build (macos-13, net5.0, -x64, false)

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 491 in src/ImageSharp/Formats/Gif/GifDecoderCore.cs

View workflow job for this annotation

GitHub Actions / Build (ubuntu-latest, netcoreapp3.1, -x64, false)

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 491 in src/ImageSharp/Formats/Gif/GifDecoderCore.cs

View workflow job for this annotation

GitHub Actions / Build (windows-latest, netcoreapp2.1, -x64, false)

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 491 in src/ImageSharp/Formats/Gif/GifDecoderCore.cs

View workflow job for this annotation

GitHub Actions / Build (windows-latest, net6.0, 6.0.x, true, -x64, false)

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 491 in src/ImageSharp/Formats/Gif/GifDecoderCore.cs

View workflow job for this annotation

GitHub Actions / Build (windows-latest, netcoreapp3.1, -x64, false)

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 491 in src/ImageSharp/Formats/Gif/GifDecoderCore.cs

View workflow job for this annotation

GitHub Actions / Build (macos-13, netcoreapp3.1, -x64, false)

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 491 in src/ImageSharp/Formats/Gif/GifDecoderCore.cs

View workflow job for this annotation

GitHub Actions / Build (windows-latest, net5.0, -x64, false)

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 491 in src/ImageSharp/Formats/Gif/GifDecoderCore.cs

View workflow job for this annotation

GitHub Actions / Build (windows-latest, net472, -x64, false)

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 491 in src/ImageSharp/Formats/Gif/GifDecoderCore.cs

View workflow job for this annotation

GitHub Actions / Build (windows-latest, net472, -x86, false)

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 491 in src/ImageSharp/Formats/Gif/GifDecoderCore.cs

View workflow job for this annotation

GitHub Actions / Build (macos-13, net6.0, 6.0.x, true, -x64, false)

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.
ImageFrame<TPixel>? currentFrame = null;

Check warning on line 492 in src/ImageSharp/Formats/Gif/GifDecoderCore.cs

View workflow job for this annotation

GitHub Actions / Build (ubuntu-latest, net5.0, -x64, false)

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 492 in src/ImageSharp/Formats/Gif/GifDecoderCore.cs

View workflow job for this annotation

GitHub Actions / Build (ubuntu-latest, net6.0, 6.0.x, true, -x64, false)

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 492 in src/ImageSharp/Formats/Gif/GifDecoderCore.cs

View workflow job for this annotation

GitHub Actions / Build (macos-13, net5.0, -x64, false)

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 492 in src/ImageSharp/Formats/Gif/GifDecoderCore.cs

View workflow job for this annotation

GitHub Actions / Build (ubuntu-latest, netcoreapp3.1, -x64, false)

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 492 in src/ImageSharp/Formats/Gif/GifDecoderCore.cs

View workflow job for this annotation

GitHub Actions / Build (windows-latest, netcoreapp2.1, -x64, false)

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 492 in src/ImageSharp/Formats/Gif/GifDecoderCore.cs

View workflow job for this annotation

GitHub Actions / Build (windows-latest, net6.0, 6.0.x, true, -x64, false)

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 492 in src/ImageSharp/Formats/Gif/GifDecoderCore.cs

View workflow job for this annotation

GitHub Actions / Build (windows-latest, netcoreapp3.1, -x64, false)

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 492 in src/ImageSharp/Formats/Gif/GifDecoderCore.cs

View workflow job for this annotation

GitHub Actions / Build (macos-13, netcoreapp3.1, -x64, false)

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 492 in src/ImageSharp/Formats/Gif/GifDecoderCore.cs

View workflow job for this annotation

GitHub Actions / Build (windows-latest, net5.0, -x64, false)

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 492 in src/ImageSharp/Formats/Gif/GifDecoderCore.cs

View workflow job for this annotation

GitHub Actions / Build (windows-latest, net472, -x64, false)

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 492 in src/ImageSharp/Formats/Gif/GifDecoderCore.cs

View workflow job for this annotation

GitHub Actions / Build (windows-latest, net472, -x86, false)

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 492 in src/ImageSharp/Formats/Gif/GifDecoderCore.cs

View workflow job for this annotation

GitHub Actions / Build (macos-13, net6.0, 6.0.x, true, -x64, false)

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.
ImageFrame<TPixel> imageFrame;

if (previousFrame is null)
Expand Down Expand Up @@ -638,7 +643,7 @@
/// <param name="stream">The <see cref="BufferedReadStream"/> containing image data.</param>
/// <param name="frameMetadata">The collection of frame metadata.</param>
/// <param name="previousFrame">The previous frame metadata.</param>
private void ReadFrameMetadata(BufferedReadStream stream, List<ImageFrameMetadata> frameMetadata, ref ImageFrameMetadata? previousFrame)

Check warning on line 646 in src/ImageSharp/Formats/Gif/GifDecoderCore.cs

View workflow job for this annotation

GitHub Actions / Build (ubuntu-latest, net5.0, -x64, false)

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 646 in src/ImageSharp/Formats/Gif/GifDecoderCore.cs

View workflow job for this annotation

GitHub Actions / Build (ubuntu-latest, net6.0, 6.0.x, true, -x64, false)

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 646 in src/ImageSharp/Formats/Gif/GifDecoderCore.cs

View workflow job for this annotation

GitHub Actions / Build (macos-13, net5.0, -x64, false)

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 646 in src/ImageSharp/Formats/Gif/GifDecoderCore.cs

View workflow job for this annotation

GitHub Actions / Build (ubuntu-latest, netcoreapp3.1, -x64, false)

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 646 in src/ImageSharp/Formats/Gif/GifDecoderCore.cs

View workflow job for this annotation

GitHub Actions / Build (windows-latest, netcoreapp2.1, -x64, false)

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 646 in src/ImageSharp/Formats/Gif/GifDecoderCore.cs

View workflow job for this annotation

GitHub Actions / Build (windows-latest, net6.0, 6.0.x, true, -x64, false)

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 646 in src/ImageSharp/Formats/Gif/GifDecoderCore.cs

View workflow job for this annotation

GitHub Actions / Build (windows-latest, netcoreapp3.1, -x64, false)

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 646 in src/ImageSharp/Formats/Gif/GifDecoderCore.cs

View workflow job for this annotation

GitHub Actions / Build (macos-13, netcoreapp3.1, -x64, false)

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 646 in src/ImageSharp/Formats/Gif/GifDecoderCore.cs

View workflow job for this annotation

GitHub Actions / Build (windows-latest, net5.0, -x64, false)

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 646 in src/ImageSharp/Formats/Gif/GifDecoderCore.cs

View workflow job for this annotation

GitHub Actions / Build (windows-latest, net472, -x64, false)

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 646 in src/ImageSharp/Formats/Gif/GifDecoderCore.cs

View workflow job for this annotation

GitHub Actions / Build (windows-latest, net472, -x86, false)

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 646 in src/ImageSharp/Formats/Gif/GifDecoderCore.cs

View workflow job for this annotation

GitHub Actions / Build (macos-13, net6.0, 6.0.x, true, -x64, false)

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.
{
this.ReadImageDescriptor(stream);

Expand Down Expand Up @@ -772,7 +777,7 @@
Span<byte> globalColorTableSpan = this.globalColorTable.GetSpan();
stream.Read(globalColorTableSpan);

//Color[] colorTable = new Color[this.logicalScreenDescriptor.GlobalColorTableSize];

Check warning on line 780 in src/ImageSharp/Formats/Gif/GifDecoderCore.cs

View workflow job for this annotation

GitHub Actions / Build (ubuntu-latest, net5.0, -x64, false)

Single line comment should begin with a space

Check warning on line 780 in src/ImageSharp/Formats/Gif/GifDecoderCore.cs

View workflow job for this annotation

GitHub Actions / Build (ubuntu-latest, net6.0, 6.0.x, true, -x64, false)

Single line comment should begin with a space

Check warning on line 780 in src/ImageSharp/Formats/Gif/GifDecoderCore.cs

View workflow job for this annotation

GitHub Actions / Build (ubuntu-latest, netcoreapp3.1, -x64, false)

Single line comment should begin with a space

Check warning on line 780 in src/ImageSharp/Formats/Gif/GifDecoderCore.cs

View workflow job for this annotation

GitHub Actions / Build (windows-latest, netcoreapp2.1, -x64, false)

Single line comment should begin with a space

Check warning on line 780 in src/ImageSharp/Formats/Gif/GifDecoderCore.cs

View workflow job for this annotation

GitHub Actions / Build (windows-latest, net6.0, 6.0.x, true, -x64, false)

Single line comment should begin with a space

Check warning on line 780 in src/ImageSharp/Formats/Gif/GifDecoderCore.cs

View workflow job for this annotation

GitHub Actions / Build (windows-latest, netcoreapp3.1, -x64, false)

Single line comment should begin with a space

Check warning on line 780 in src/ImageSharp/Formats/Gif/GifDecoderCore.cs

View workflow job for this annotation

GitHub Actions / Build (windows-latest, net5.0, -x64, false)

Single line comment should begin with a space

Check warning on line 780 in src/ImageSharp/Formats/Gif/GifDecoderCore.cs

View workflow job for this annotation

GitHub Actions / Build (windows-latest, net472, -x64, false)

Single line comment should begin with a space

Check warning on line 780 in src/ImageSharp/Formats/Gif/GifDecoderCore.cs

View workflow job for this annotation

GitHub Actions / Build (windows-latest, net472, -x86, false)

Single line comment should begin with a space
//ReadOnlySpan<Rgb24> rgbTable = MemoryMarshal.Cast<byte, Rgb24>(globalColorTableSpan);
//for (int i = 0; i < colorTable.Length; i++)
//{
Expand Down
33 changes: 23 additions & 10 deletions tests/ImageSharp.Tests/Formats/Gif/GifDecoderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -183,16 +183,16 @@ public void Issue1530_BadDescriptorDimensions<TPixel>(TestImageProvider<TPixel>
image.CompareToReferenceOutputMultiFrame(provider, ImageComparer.Exact);
}

// https://github.com/SixLabors/ImageSharp/issues/2758
[Theory]
[WithFile(TestImages.Gif.Issues.Issue2758, PixelTypes.Rgba32)]
public void Issue2758_BadDescriptorDimensions<TPixel>(TestImageProvider<TPixel> provider)
where TPixel : unmanaged, IPixel<TPixel>
{
using Image<TPixel> image = provider.GetImage();
image.DebugSaveMultiFrame(provider);
image.CompareToReferenceOutputMultiFrame(provider, ImageComparer.Exact);
}
// https://github.com/SixLabors/ImageSharp/issues/2758
[Theory]
[WithFile(TestImages.Gif.Issues.Issue2758, PixelTypes.Rgba32)]
public void Issue2758_BadDescriptorDimensions<TPixel>(TestImageProvider<TPixel> provider)
where TPixel : unmanaged, IPixel<TPixel>
{
using Image<TPixel> image = provider.GetImage();
image.DebugSaveMultiFrame(provider);
image.CompareToReferenceOutputMultiFrame(provider, ImageComparer.Exact);
}

// https://github.com/SixLabors/ImageSharp/issues/405
[Theory]
Expand Down Expand Up @@ -329,5 +329,18 @@ public void Issue2859_LZWPixelStackOverflow<TPixel>(TestImageProvider<TPixel> pr
image.DebugSaveMultiFrame(provider);
image.CompareToReferenceOutputMultiFrame(provider, ImageComparer.Exact);
}

// https://github.com/SixLabors/ImageSharp/issues/2953
[Theory]
[WithFile(TestImages.Gif.Issues.Issue2953, PixelTypes.Rgba32)]
public void Issue2953<TPixel>(TestImageProvider<TPixel> provider)
where TPixel : unmanaged, IPixel<TPixel>
{
// We should throw a InvalidImageContentException when trying to identify or load an invalid GIF file.
var testFile = TestFile.Create(provider.SourceFileOrDescription);

Assert.Throws<InvalidImageContentException>(() => Image.Identify(testFile.FullPath));
Assert.Throws<InvalidImageContentException>(() => Image.Load(testFile.FullPath));
}
}
}
1 change: 1 addition & 0 deletions tests/ImageSharp.Tests/TestImages.cs
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,7 @@ public static class Issues
public const string Issue2758 = "Gif/issues/issue_2758.gif";
public const string Issue2859_A = "Gif/issues/issue_2859_A.gif";
public const string Issue2859_B = "Gif/issues/issue_2859_B.gif";
public const string Issue2953 = "Gif/issues/issue_2953.gif";
}

public static readonly string[] All = { Rings, Giphy, Cheers, Trans, Kumin, Leo, Ratio4x1, Ratio1x4 };
Expand Down
3 changes: 3 additions & 0 deletions tests/Images/Input/Gif/issues/issue_2953.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading