From 9d9bad40f35f9b8e01897cbbc2449d30ec5e8fe6 Mon Sep 17 00:00:00 2001 From: Marek Kasik Date: Tue, 20 Sep 2016 11:04:58 +0200 Subject: [PATCH] Don't crash when calling cmsGetColorSpace() Initialize RGBProfile and displayProfile before their use if they were not initialized in GfxState's constructor. https://bugs.freedesktop.org/show_bug.cgi?id=97870 --- poppler/GfxState.cc | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/poppler/GfxState.cc b/poppler/GfxState.cc index 368ee27..a57ca6c 100644 --- a/poppler/GfxState.cc +++ b/poppler/GfxState.cc @@ -2049,8 +2049,25 @@ GfxColorSpace *GfxICCBasedColorSpace::parse(Array *arr, OutputDev *out, GfxState if (hp == 0) { error(errSyntaxWarning, -1, "read ICCBased color space profile error"); } else { - cmsHPROFILE dhp = (state != NULL && state->getDisplayProfile() != NULL) ? state->getDisplayProfile() : displayProfile; - if (dhp == NULL) dhp = RGBProfile; + cmsHPROFILE dhp; + + if (state != NULL && state->getDisplayProfile() != NULL) { + dhp = state->getDisplayProfile(); + } + else { + if (displayProfile == NULL) { + GfxColorSpace::setupColorProfiles(); + } + dhp = displayProfile; + } + + if (dhp == NULL) { + if (RGBProfile == NULL) { + GfxColorSpace::setupColorProfiles(); + } + dhp = RGBProfile; + } + unsigned int cst = getCMSColorSpaceType(cmsGetColorSpace(hp)); unsigned int dNChannels = getCMSNChannels(cmsGetColorSpace(dhp)); unsigned int dcst = getCMSColorSpaceType(cmsGetColorSpace(dhp)); -- 2.9.3