Closed KirillAldashkin closed 1 month ago
Already found the reason: https://github.com/SixLabors/ImageSharp/blob/65ae451622f5f801f1002e731129d7b105fa430c/src/ImageSharp/Image.WrapMemory.cs#L428
bufferSizeInBytes
(in bytes) is compared with memoryManager.Memory.Span.Length
(in pixels).
X
bytes is smaller than X
multibyte pixels so it overruns passed buffer
Prerequisites
DEBUG
andRELEASE
modeImageSharp version
3.1.5
Other ImageSharp packages and versions
none
Environment (Operating system, version and so on)
Windows 11 23H2 22631.3880
.NET Framework version
.NET SDK 8.0
Description
This happens when using
WrapMemory<TPixel>(void* pointer, int bufferSizeInBytes, int width, int height)
and passing buffer that is too small for givenwidth
,height
andTPixel
even with correctbufferSizeInBytes
valueExpected behaviour
Exception saying that given buffer is too small for given image size and pixel format
Actual behaviour
Fatal error. Internal CLR error
Steps to Reproduce
Run this code
Images
No response