From 21894f1cdec8815f36fb7560af36c8fafe7062c1 Mon Sep 17 00:00:00 2001 From: Nico Weber Date: Sun, 5 Nov 2023 22:27:00 +0100 Subject: [PATCH] LibPDF: Fix typos in DeviceN colorspace scaffolding * Compare array size to 3 and 4, not 4 and 5 * Fix literal typo in error message Fixes crash processing 0000906.pdf from 0000.zip from the pdf/a dataset. --- Userland/Libraries/LibPDF/ColorSpace.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Userland/Libraries/LibPDF/ColorSpace.cpp b/Userland/Libraries/LibPDF/ColorSpace.cpp index 16a1aa22f7..ffa66a0f0a 100644 --- a/Userland/Libraries/LibPDF/ColorSpace.cpp +++ b/Userland/Libraries/LibPDF/ColorSpace.cpp @@ -159,8 +159,9 @@ PDFErrorOr> DeviceNColorSpace::create(Document* // "[ /DeviceN names alternateSpace tintTransform ] // or // [ /DeviceN names alternateSpace tintTransform attributes ]" - if (parameters.size() != 4 && parameters.size() != 5) - return Error { Error::Type::MalformedPDF, "DevicN color space expects 4 or 5 parameters" }; + // (`/DeviceN` is already stripped from the array by the time we get here.) + if (parameters.size() != 3 && parameters.size() != 4) + return Error { Error::Type::MalformedPDF, "DeviceN color space expects 4 or 5 parameters" }; // "The names parameter is an array of name objects specifying the individual color components. // The length of the array determines the number of components in the DeviceN color space"