summaryrefslogtreecommitdiff
path: root/core/src/fpdfapi/fpdf_page/fpdf_page_pattern.cpp
diff options
context:
space:
mode:
authorBo Xu <bo_xu@foxitsoftware.com>2014-10-14 17:10:06 -0700
committerBo Xu <bo_xu@foxitsoftware.com>2014-10-14 17:10:06 -0700
commite1177425a656f915657f948d965193a019702a52 (patch)
treeb3213672a9af719ffe6b9b519a828d587886f289 /core/src/fpdfapi/fpdf_page/fpdf_page_pattern.cpp
parent35d720aff01c5ea778c16ac1e31c56f68490f10b (diff)
downloadpdfium-e1177425a656f915657f948d965193a019702a52.tar.xz
Store the address of the page data map's value for proper referencing.
CPDF_Pattern objects are counted and maintained in m_PatternedMap. When a CPDF_Pattern object "pattern" is deleted, it's address is marked as NULL in m_PatternMap. This patch stores the address of CPDF_Pattern's adderss in all objects that references "pattern", to ensure valid referencing after deletion. BUG=416319, 419976, 418392 R=tsepez@chromium.org Review URL: https://codereview.chromium.org/656753002
Diffstat (limited to 'core/src/fpdfapi/fpdf_page/fpdf_page_pattern.cpp')
-rw-r--r--core/src/fpdfapi/fpdf_page/fpdf_page_pattern.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/core/src/fpdfapi/fpdf_page/fpdf_page_pattern.cpp b/core/src/fpdfapi/fpdf_page/fpdf_page_pattern.cpp
index 67ea4fee65..467ef9b3f6 100644
--- a/core/src/fpdfapi/fpdf_page/fpdf_page_pattern.cpp
+++ b/core/src/fpdfapi/fpdf_page/fpdf_page_pattern.cpp
@@ -83,6 +83,7 @@ CPDF_ShadingPattern::CPDF_ShadingPattern(CPDF_Document* pDoc, CPDF_Object* pPatt
for (int i = 0; i < 4; i ++) {
m_pFunctions[i] = NULL;
}
+ m_pCountedCS = NULL;
}
CPDF_ShadingPattern::~CPDF_ShadingPattern()
{
@@ -96,12 +97,13 @@ void CPDF_ShadingPattern::Clear()
}
m_pFunctions[i] = NULL;
}
- CPDF_ColorSpace* pCS = m_pCS;
- if (!m_bForceClear && pCS && m_pDocument) {
+ CPDF_ColorSpace* pCS = m_pCountedCS ? m_pCountedCS->m_Obj : NULL;
+ if (pCS && m_pDocument) {
m_pDocument->GetPageData()->ReleaseColorSpace(pCS->GetArray());
}
m_ShadingType = 0;
m_pCS = NULL;
+ m_pCountedCS = NULL;
m_nFuncs = 0;
}
FX_BOOL CPDF_ShadingPattern::Load()
@@ -141,6 +143,9 @@ FX_BOOL CPDF_ShadingPattern::Load()
}
CPDF_DocPageData* pDocPageData = m_pDocument->GetPageData();
m_pCS = pDocPageData->GetColorSpace(pCSObj, NULL);
+ if (m_pCS) {
+ m_pCountedCS = pDocPageData->FindColorSpacePtr(m_pCS->GetArray());
+ }
m_ShadingType = pShadingDict->GetInteger(FX_BSTRC("ShadingType"));
return TRUE;
}