summaryrefslogtreecommitdiff
path: root/core/fpdfapi/page/cpdf_docpagedata.cpp
diff options
context:
space:
mode:
authorHenrique Nakashima <hnakashima@chromium.org>2017-08-30 17:02:01 -0400
committerChromium commit bot <commit-bot@chromium.org>2017-08-31 19:34:56 +0000
commitce9ad1bee792856c2d9e940ecffff97145e18d32 (patch)
tree8410b6a25c2f99f91c2bab98d9d764c11ed159b5 /core/fpdfapi/page/cpdf_docpagedata.cpp
parent670c4fdea0acb9663145b96bec1fbf76279781df (diff)
downloadpdfium-ce9ad1bee792856c2d9e940ecffff97145e18d32.tar.xz
Fix colorspace loading for mutually referencing colorspaces.
For example, Indexed colorspace A uses ICC Based colorspace B as its "base". B declares A as its "Alternate" fallback. Bug: chromium:759012 Change-Id: I4b78e68b9a77456050ecae4452837495546bf93d Reviewed-on: https://pdfium-review.googlesource.com/12471 Commit-Queue: Henrique Nakashima <hnakashima@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org> Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Diffstat (limited to 'core/fpdfapi/page/cpdf_docpagedata.cpp')
-rw-r--r--core/fpdfapi/page/cpdf_docpagedata.cpp21
1 files changed, 10 insertions, 11 deletions
diff --git a/core/fpdfapi/page/cpdf_docpagedata.cpp b/core/fpdfapi/page/cpdf_docpagedata.cpp
index 71143d0b6c..1af9d6ee22 100644
--- a/core/fpdfapi/page/cpdf_docpagedata.cpp
+++ b/core/fpdfapi/page/cpdf_docpagedata.cpp
@@ -212,10 +212,10 @@ CPDF_ColorSpace* CPDF_DocPageData::GetColorSpace(
CPDF_Object* pCSObj,
const CPDF_Dictionary* pResources) {
std::set<CPDF_Object*> visited;
- return GetColorSpaceImpl(pCSObj, pResources, &visited);
+ return GetColorSpaceGuarded(pCSObj, pResources, &visited);
}
-CPDF_ColorSpace* CPDF_DocPageData::GetColorSpaceImpl(
+CPDF_ColorSpace* CPDF_DocPageData::GetColorSpaceGuarded(
CPDF_Object* pCSObj,
const CPDF_Dictionary* pResources,
std::set<CPDF_Object*>* pVisited) {
@@ -225,15 +225,16 @@ CPDF_ColorSpace* CPDF_DocPageData::GetColorSpaceImpl(
if (pdfium::ContainsKey(*pVisited, pCSObj))
return nullptr;
+ pdfium::ScopedSetInsertion<CPDF_Object*> insertion(pVisited, pCSObj);
+
if (pCSObj->IsName()) {
CFX_ByteString name = pCSObj->GetString();
CPDF_ColorSpace* pCS = CPDF_ColorSpace::ColorspaceFromName(name);
if (!pCS && pResources) {
CPDF_Dictionary* pList = pResources->GetDictFor("ColorSpace");
if (pList) {
- pdfium::ScopedSetInsertion<CPDF_Object*> insertion(pVisited, pCSObj);
- return GetColorSpaceImpl(pList->GetDirectObjectFor(name), nullptr,
- pVisited);
+ return GetColorSpaceGuarded(pList->GetDirectObjectFor(name), nullptr,
+ pVisited);
}
}
if (!pCS || !pResources)
@@ -258,8 +259,7 @@ CPDF_ColorSpace* CPDF_DocPageData::GetColorSpaceImpl(
if (!pDefaultCS)
return pCS;
- pdfium::ScopedSetInsertion<CPDF_Object*> insertion(pVisited, pCSObj);
- return GetColorSpaceImpl(pDefaultCS, nullptr, pVisited);
+ return GetColorSpaceGuarded(pDefaultCS, nullptr, pVisited);
}
CPDF_Array* pArray = pCSObj->AsArray();
@@ -267,9 +267,8 @@ CPDF_ColorSpace* CPDF_DocPageData::GetColorSpaceImpl(
return nullptr;
if (pArray->GetCount() == 1) {
- pdfium::ScopedSetInsertion<CPDF_Object*> insertion(pVisited, pCSObj);
- return GetColorSpaceImpl(pArray->GetDirectObjectAt(0), pResources,
- pVisited);
+ return GetColorSpaceGuarded(pArray->GetDirectObjectAt(0), pResources,
+ pVisited);
}
CPDF_CountedColorSpace* csData = nullptr;
@@ -282,7 +281,7 @@ CPDF_ColorSpace* CPDF_DocPageData::GetColorSpaceImpl(
}
std::unique_ptr<CPDF_ColorSpace> pCS =
- CPDF_ColorSpace::Load(m_pPDFDoc.Get(), pArray);
+ CPDF_ColorSpace::Load(m_pPDFDoc.Get(), pArray, pVisited);
if (!pCS)
return nullptr;