From 9d3cd0a429647d4a7214d931bc2061f280347e63 Mon Sep 17 00:00:00 2001 From: BobLd <38405645+BobLd@users.noreply.github.com> Date: Fri, 7 Nov 2025 19:43:26 +0000 Subject: [PATCH] Check for array size before slice in ColorSpaceDetailsByteConverter.Convert() --- src/UglyToad.PdfPig/Images/ColorSpaceDetailsByteConverter.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/UglyToad.PdfPig/Images/ColorSpaceDetailsByteConverter.cs b/src/UglyToad.PdfPig/Images/ColorSpaceDetailsByteConverter.cs index 28deb90e..a2ca37a6 100644 --- a/src/UglyToad.PdfPig/Images/ColorSpaceDetailsByteConverter.cs +++ b/src/UglyToad.PdfPig/Images/ColorSpaceDetailsByteConverter.cs @@ -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