Check for array size before slice in ColorSpaceDetailsByteConverter.Convert()

This commit is contained in:
BobLd
2025-11-07 19:43:26 +00:00
parent b49e5aa697
commit 9d3cd0a429

View File

@@ -39,7 +39,7 @@
var strideWidth = decoded.Length / imageHeight / bytesPerPixel;
if (strideWidth != imageWidth)
{
if (bytesPerPixel > 1)
if (bytesPerPixel > 1 && imageWidth * imageHeight * bytesPerPixel < decoded.Length)
{
// Fixed thanks to / see discussion at https://github.com/UglyToad/PdfPig/issues/1183
// Unclear what should be done here, we assume we can just remove the trailing bytes