From ba371349b37a65edc3085bd61b05d2ea3b4ae632 Mon Sep 17 00:00:00 2001 From: Brian Popow Date: Tue, 11 Feb 2020 15:31:13 +0100 Subject: [PATCH] Increase LimitAllocatorBufferCapacity to 400 for RLE tests. Add info to ImageFormatException that this may happen for large RLE images --- src/ImageSharp/Formats/Bmp/BmpDecoder.cs | 2 +- tests/ImageSharp.Tests/Formats/Bmp/BmpDecoderTests.cs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ImageSharp/Formats/Bmp/BmpDecoder.cs b/src/ImageSharp/Formats/Bmp/BmpDecoder.cs index 150ce243e6..e5546b3613 100644 --- a/src/ImageSharp/Formats/Bmp/BmpDecoder.cs +++ b/src/ImageSharp/Formats/Bmp/BmpDecoder.cs @@ -45,7 +45,7 @@ namespace SixLabors.ImageSharp.Formats.Bmp // TODO: use InvalidImageContentException here, if we decide to define it // https://github.com/SixLabors/ImageSharp/issues/1110 - throw new ImageFormatException($"Can not decode image. Failed to allocate buffers for possibly degenerate dimensions: {dims.Width}x{dims.Height}.", ex); + throw new ImageFormatException($"Can not decode image. Failed to allocate buffers for possibly degenerate dimensions: {dims.Width}x{dims.Height}. This error can happen for very large RLE bitmaps, which are not supported.", ex); } } diff --git a/tests/ImageSharp.Tests/Formats/Bmp/BmpDecoderTests.cs b/tests/ImageSharp.Tests/Formats/Bmp/BmpDecoderTests.cs index c28aa6b256..2645160639 100644 --- a/tests/ImageSharp.Tests/Formats/Bmp/BmpDecoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Bmp/BmpDecoderTests.cs @@ -261,7 +261,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Bmp { if (enforceDiscontiguousBuffers) { - provider.LimitAllocatorBufferCapacity().InBytes(100); + provider.LimitAllocatorBufferCapacity().InBytes(400); } using (Image image = provider.GetImage(new BmpDecoder { RleSkippedPixelHandling = RleSkippedPixelHandling.FirstColorOfPalette })) @@ -283,7 +283,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Bmp { if (enforceNonContiguous) { - provider.LimitAllocatorBufferCapacity().InBytes(50); + provider.LimitAllocatorBufferCapacity().InBytes(400); } using (Image image = provider.GetImage(new BmpDecoder { RleSkippedPixelHandling = RleSkippedPixelHandling.Black }))