Skip to content

Commit 40643c1

Browse files
Merge pull request #2880 from SixLabors/js/fix-2859
V3: Gracefully handle LZW overflows
2 parents b8d1cd8 + 20e5596 commit 40643c1

File tree

9 files changed

+223
-133
lines changed

9 files changed

+223
-133
lines changed

.github/workflows/build-and-test.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ jobs:
146146
XUNIT_PATH: .\tests\ImageSharp.Tests # Required for xunit
147147

148148
- name: Export Failed Output
149-
uses: actions/upload-artifact@v3
149+
uses: actions/upload-artifact@v4
150150
if: failure()
151151
with:
152152
name: actual_output_${{ runner.os }}_${{ matrix.options.framework }}${{ matrix.options.runtime }}.zip

src/ImageSharp/Formats/Gif/LzwDecoder.cs

+193-132
Large diffs are not rendered by default.

tests/ImageSharp.Tests/Formats/Gif/GifDecoderTests.cs

+12
Original file line numberDiff line numberDiff line change
@@ -334,4 +334,16 @@ public void IssueTooLargeLzwBits<TPixel>(TestImageProvider<TPixel> provider)
334334
image.DebugSaveMultiFrame(provider);
335335
image.CompareToReferenceOutputMultiFrame(provider, ImageComparer.Exact);
336336
}
337+
338+
// https://github.com/SixLabors/ImageSharp/issues/2859
339+
[Theory]
340+
[WithFile(TestImages.Gif.Issues.Issue2859_A, PixelTypes.Rgba32)]
341+
[WithFile(TestImages.Gif.Issues.Issue2859_B, PixelTypes.Rgba32)]
342+
public void Issue2859_LZWPixelStackOverflow<TPixel>(TestImageProvider<TPixel> provider)
343+
where TPixel : unmanaged, IPixel<TPixel>
344+
{
345+
using Image<TPixel> image = provider.GetImage();
346+
image.DebugSaveMultiFrame(provider);
347+
image.CompareToReferenceOutputMultiFrame(provider, ImageComparer.Exact);
348+
}
337349
}

tests/ImageSharp.Tests/TestImages.cs

+2
Original file line numberDiff line numberDiff line change
@@ -535,6 +535,8 @@ public static class Issues
535535
public const string Issue2450_B = "Gif/issues/issue_2450_2.gif";
536536
public const string Issue2198 = "Gif/issues/issue_2198.gif";
537537
public const string Issue2758 = "Gif/issues/issue_2758.gif";
538+
public const string Issue2859_A = "Gif/issues/issue_2859_A.gif";
539+
public const string Issue2859_B = "Gif/issues/issue_2859_B.gif";
538540
}
539541

540542
public static readonly string[] Animated =
Loading
Loading

0 commit comments

Comments
 (0)