Skip to content

Commit 43f952c

Browse files
committed
Throw InvalidImageContentException when frame control chunk does not have enough data
1 parent 36334cd commit 43f952c

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,13 @@ public void WriteTo(Span<byte> buffer)
147147
/// <param name="data">The data to parse.</param>
148148
/// <returns>The parsed fcTL.</returns>
149149
public static FrameControl Parse(ReadOnlySpan<byte> data)
150-
=> new(
150+
{
151+
if (data.Length < Size)
152+
{
153+
PngThrowHelper.ThrowInvalidImageContentException("The Frame Control Chunk does not contain enough data!");
154+
}
155+
156+
return new(
151157
sequenceNumber: BinaryPrimitives.ReadUInt32BigEndian(data[..4]),
152158
width: BinaryPrimitives.ReadUInt32BigEndian(data[4..8]),
153159
height: BinaryPrimitives.ReadUInt32BigEndian(data[8..12]),
@@ -157,4 +163,5 @@ public static FrameControl Parse(ReadOnlySpan<byte> data)
157163
delayDenominator: BinaryPrimitives.ReadUInt16BigEndian(data[22..24]),
158164
disposalMode: (FrameDisposalMode)(data[24] + 1),
159165
blendMode: (FrameBlendMode)data[25]);
166+
}
160167
}

0 commit comments

Comments
 (0)