Skip to content

Commit 4e81c02

Browse files
committed
Add test case for Issue #3093
1 parent 43f952c commit 4e81c02

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

src/ImageSharp/Formats/Png/Chunks/FrameControl.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ public static FrameControl Parse(ReadOnlySpan<byte> data)
150150
{
151151
if (data.Length < Size)
152152
{
153-
PngThrowHelper.ThrowInvalidImageContentException("The Frame Control Chunk does not contain enough data!");
153+
PngThrowHelper.ThrowInvalidImageContentException("The frame control chunk does not contain enough data!");
154154
}
155155

156156
return new(

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,22 @@ public void Decode_TruncatedPhysChunk_ExceptionIsThrown()
9292
Assert.Equal("pHYs chunk is too short", exception.Message);
9393
}
9494

95+
// https://github.com/SixLabors/ImageSharp/issues/3093
96+
[Fact]
97+
public void Decode_TruncatedFrameControlChunk_ExceptionIsThrown()
98+
{
99+
// PNG signature + truncated frame control chunk
100+
byte[] payload = Convert.FromHexString(
101+
"89504e470d0a1a0a424d3a00000000007f000000000028030405060000000100" +
102+
"000101002000000000000000000000000000ff00006663544cff190000000000" +
103+
"010000424d000100000101002000000000");
104+
105+
using MemoryStream stream = new(payload);
106+
InvalidImageContentException exception = Assert.Throws<InvalidImageContentException>(() => Image.Load<Rgba32>(stream));
107+
108+
Assert.Equal("The frame control chunk does not contain enough data!", exception.Message);
109+
}
110+
95111
// https://github.com/SixLabors/ImageSharp/issues/3079
96112
[Fact]
97113
public void Decode_CompressedTxtChunk_WithTruncatedData_DoesNotThrow()

0 commit comments

Comments
 (0)