Browse Source

fixed #178

af/merge-core
Anton Firszov 9 years ago
parent
commit
54f8bb6ebf
  1. 7
      src/ImageSharp/Formats/Jpeg/GolangPort/Components/Decoder/OrigJpegScanDecoder.cs
  2. 18
      tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.cs
  3. 2
      tests/ImageSharp.Tests/TestImages.cs
  4. 2
      tests/Images/External
  5. 0
      tests/Images/Input/Jpg/issues/Issue178-BadCoeffsProgressive-Lemon.jpg

7
src/ImageSharp/Formats/Jpeg/GolangPort/Components/Decoder/OrigJpegScanDecoder.cs

@ -605,12 +605,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.GolangPort.Components.Decoder
return;
}
if (zig > this.zigEnd)
{
throw new ImageFormatException($"Too many coefficients {zig} > {this.zigEnd}");
}
if (z != 0)
if (z != 0 && zig <= this.zigEnd)
{
// b[Unzig[zig]] = z;
Block8x8.SetScalarAt(b, this.pointers.Unzig[zig], (short)z);

18
tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.cs

@ -45,7 +45,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg
{
TestImages.Jpeg.Progressive.Fb, TestImages.Jpeg.Progressive.Progress,
TestImages.Jpeg.Progressive.Festzug, TestImages.Jpeg.Progressive.Bad.BadEOF,
TestImages.Jpeg.Issues.ProgressiveWithTooManyCoefficients178
TestImages.Jpeg.Issues.BadCoeffsProgressive178
};
public const PixelTypes CommonNonDefaultPixelTypes = PixelTypes.Rgba32 | PixelTypes.Argb32 | PixelTypes.RgbaVector;
@ -69,16 +69,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg
private static IImageDecoder OrigJpegDecoder => new OrigJpegDecoder();
private static IImageDecoder PdfJsJpegDecoder => new JpegDecoder();
[Fact(Skip = "Doesn't really matter")]
public void ParseStream_BasicPropertiesAreCorrect1_Orig()
{
using (OrigJpegDecoderCore decoder = JpegFixture.ParseStream(TestImages.Jpeg.Progressive.Progress))
{
VerifyJpeg.VerifyComponentSizes3(decoder.Components, 43, 61, 22, 31, 22, 31);
}
}
[Fact]
public void ParseStream_BasicPropertiesAreCorrect1_PdfJs()
{
@ -199,6 +190,11 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg
private void CompareJpegDecodersImpl<TPixel>(TestImageProvider<TPixel> provider, string testName)
where TPixel : struct, IPixel<TPixel>
{
if (TestEnvironment.RunsOnCI) // Debug only test
{
return;
}
this.Output.WriteLine(provider.SourceFileOrDescription);
provider.Utility.TestName = testName;

2
tests/ImageSharp.Tests/TestImages.cs

@ -116,7 +116,7 @@ namespace SixLabors.ImageSharp.Tests
{
public const string CriticalEOF214 = "Jpg/issues/Issue214-CriticalEOF.jpg";
public const string Issue159Girl = "Jpg/issues/Issue159Girl.jpg";
public const string ProgressiveWithTooManyCoefficients178 = "Jpg/issues/Issue178Lemon-ProgressiveWithTooManyCoefficients.jpg";
public const string BadCoeffsProgressive178 = "Jpg/issues/Issue178-BadCoeffsProgressive-Lemon.jpg";
}
public static readonly string[] All = Baseline.All.Concat(Progressive.All).ToArray();

2
tests/Images/External

@ -1 +1 @@
Subproject commit d91054b0e00001ea90e3098f7057c741893365c4
Subproject commit 90cd8c2dae16b18bb99e8c2166da72b3159e58c4

0
tests/Images/Input/Jpg/issues/Issue178Lemon-ProgressiveWithTooManyCoefficients.jpg → tests/Images/Input/Jpg/issues/Issue178-BadCoeffsProgressive-Lemon.jpg

Loading…
Cancel
Save