From ba41c7a0f80da0422a0aa9c4bff3409d51b1b54a Mon Sep 17 00:00:00 2001 From: Nico Weber Date: Sun, 12 Nov 2023 15:03:50 +0100 Subject: [PATCH] LibPDF: Tolerate an indirect object as dict for CIE-based color spaces Namely, for CalGrayColorSpace, CalRGBColorSpace, LabColorSpace. Fixes a crash rendering any page of Adobe's 5014.CIDFont_Spec.pdf (which uses CalRGBColorSpace with an indirect dict: The dict is object `92 0`, and many color spaces are inline objects referring to it). --- Userland/Libraries/LibPDF/ColorSpace.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Userland/Libraries/LibPDF/ColorSpace.cpp b/Userland/Libraries/LibPDF/ColorSpace.cpp index 263b953d8bdb24..16e9d5182139b3 100644 --- a/Userland/Libraries/LibPDF/ColorSpace.cpp +++ b/Userland/Libraries/LibPDF/ColorSpace.cpp @@ -314,7 +314,7 @@ PDFErrorOr> CalGrayColorSpace::create(Document* if (parameters.size() != 1) return Error { Error::Type::MalformedPDF, "Gray color space expects one parameter" }; - auto param = parameters[0]; + auto param = TRY(document->resolve(parameters[0])); if (!param.has>() || !param.get>()->is()) return Error { Error::Type::MalformedPDF, "Gray color space expects a dict parameter" }; @@ -384,7 +384,7 @@ PDFErrorOr> CalRGBColorSpace::create(Document* d if (parameters.size() != 1) return Error { Error::Type::MalformedPDF, "RGB color space expects one parameter" }; - auto param = parameters[0]; + auto param = TRY(document->resolve(parameters[0])); if (!param.has>() || !param.get>()->is()) return Error { Error::Type::MalformedPDF, "RGB color space expects a dict parameter" }; @@ -554,7 +554,7 @@ PDFErrorOr> LabColorSpace::create(Document* documen if (parameters.size() != 1) return Error { Error::Type::MalformedPDF, "Lab color space expects one parameter" }; - auto param = parameters[0]; + auto param = TRY(document->resolve(parameters[0])); if (!param.has>() || !param.get>()->is()) return Error { Error::Type::MalformedPDF, "Lab color space expects a dict parameter" };