Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitd7f7d5a

Browse files
Correctly break during decoding
1 parentb496109 commitd7f7d5a

File tree

4 files changed

+22
-6
lines changed

4 files changed

+22
-6
lines changed

‎src/ImageSharp/Formats/Png/PngDecoderCore.cs‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -204,18 +204,13 @@ public Image<TPixel> Decode<TPixel>(BufferedReadStream stream, CancellationToken
204204
break;
205205
casePngChunkType.FrameControl:
206206
frameCount++;
207-
if(frameCount==this.maxFrames)
208-
{
209-
break;
210-
}
211-
212207
currentFrame=null;
213208
currentFrameControl=this.ReadFrameControlChunk(chunk.Data.GetSpan());
214209
break;
215210
casePngChunkType.FrameData:
216211
if(frameCount==this.maxFrames)
217212
{
218-
break;
213+
gotoEOF;
219214
}
220215

221216
if(imageisnull)
@@ -271,6 +266,11 @@ public Image<TPixel> Decode<TPixel>(BufferedReadStream stream, CancellationToken
271266
previousFrameControl=currentFrameControl;
272267
}
273268

269+
if(frameCount==this.maxFrames)
270+
{
271+
gotoEOF;
272+
}
273+
274274
break;
275275
casePngChunkType.Palette:
276276
this.palette=chunk.Data.GetSpan().ToArray();

‎tests/ImageSharp.Tests/Formats/Png/PngDecoderTests.cs‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -701,4 +701,14 @@ public void Decode_BadPalette(string file)
701701
stringpath=Path.GetFullPath(Path.Combine(TestEnvironment.InputImagesDirectoryFullPath,file));
702702
usingImageimage=Image.Load(path);
703703
}
704+
705+
[Theory]
706+
[WithFile(TestImages.Png.Issue2752,PixelTypes.Rgba32)]
707+
publicvoidCanDecodeJustOneFrame<TPixel>(TestImageProvider<TPixel>provider)
708+
whereTPixel: unmanaged,IPixel<TPixel>
709+
{
710+
DecoderOptionsoptions=new(){MaxFrames=1};
711+
usingImage<TPixel>image=provider.GetImage(PngDecoder.Instance,options);
712+
Assert.Equal(1,image.Frames.Count);
713+
}
704714
}

‎tests/ImageSharp.Tests/TestImages.cs‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,9 @@ public static class Png
156156
// Issue 2668: https://github.com/SixLabors/ImageSharp/issues/2668
157157
publicconststringIssue2668="Png/issues/Issue_2668.png";
158158

159+
// Issue 2752: https://github.com/SixLabors/ImageSharp/issues/2752
160+
publicconststringIssue2752="Png/issues/Issue_2752.png";
161+
159162
publicstaticclassBad
160163
{
161164
publicconststringMissingDataChunk="Png/xdtn0g01.png";
Lines changed: 3 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp