Skip to content

Commit c1b4bbd

Browse files
Merge branch 'master' into js/faster-transforms
2 parents b25e102 + 91b899f commit c1b4bbd

File tree

4 files changed

+19
-4
lines changed

4 files changed

+19
-4
lines changed

src/ImageSharp/Formats/Png/PngDecoderCore.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1101,10 +1101,7 @@ private bool TryReadChunk(out PngChunk chunk)
11011101

11021102
while (length < 0 || length > (this.currentStream.Length - this.currentStream.Position))
11031103
{
1104-
// Not a valid chunk so we skip back all but one of the four bytes we have just read.
1105-
// That lets us read one byte at a time until we reach a known chunk.
1106-
this.currentStream.Position -= 3;
1107-
1104+
// Not a valid chunk so try again until we reach a known chunk.
11081105
if (!this.TryReadChunkLength(out length))
11091106
{
11101107
chunk = default;

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,23 @@ public void Issue1014<TPixel>(TestImageProvider<TPixel> provider)
243243
Assert.Null(ex);
244244
}
245245

246+
[Theory]
247+
[WithFile(TestImages.Png.Issue1127, PixelTypes.Rgba32)]
248+
public void Issue1127<TPixel>(TestImageProvider<TPixel> provider)
249+
where TPixel : struct, IPixel<TPixel>
250+
{
251+
System.Exception ex = Record.Exception(
252+
() =>
253+
{
254+
using (Image<TPixel> image = provider.GetImage(PngDecoder))
255+
{
256+
image.DebugSave(provider);
257+
image.CompareToOriginal(provider, ImageComparer.Exact);
258+
}
259+
});
260+
Assert.Null(ex);
261+
}
262+
246263
[Theory]
247264
[WithFile(TestImages.Png.Splash, PixelTypes.Rgba32)]
248265
[WithFile(TestImages.Png.Bike, PixelTypes.Rgba32)]

tests/ImageSharp.Tests/TestImages.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ public static class Png
9090
public const string Issue1014_4 = "Png/issues/Issue_1014_4.png";
9191
public const string Issue1014_5 = "Png/issues/Issue_1014_5.png";
9292
public const string Issue1014_6 = "Png/issues/Issue_1014_6.png";
93+
public const string Issue1127 = "Png/issues/Issue_1127.png";
9394

9495
public static class Bad
9596
{
13.5 KB
Loading

0 commit comments

Comments
 (0)