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.
This commit is contained in:
Nico Weber 2023-11-05 22:27:00 +01:00 committed by Andreas Kling
parent b6da9abfb2
commit 21894f1cde

View file

@ -159,8 +159,9 @@ PDFErrorOr<NonnullRefPtr<DeviceNColorSpace>> 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"