summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/fpdfapi/page/cpdf_shadingpattern.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/core/fpdfapi/page/cpdf_shadingpattern.cpp b/core/fpdfapi/page/cpdf_shadingpattern.cpp
index c21f51cb77..542c4051c5 100644
--- a/core/fpdfapi/page/cpdf_shadingpattern.cpp
+++ b/core/fpdfapi/page/cpdf_shadingpattern.cpp
@@ -45,11 +45,13 @@ CPDF_ShadingPattern::CPDF_ShadingPattern(CPDF_Document* pDoc,
}
CPDF_ShadingPattern::~CPDF_ShadingPattern() {
- CPDF_ColorSpace* pCS = m_pCountedCS ? m_pCountedCS->get() : nullptr;
- if (pCS) {
+ CPDF_ColorSpace* pCountedCS = m_pCountedCS ? m_pCountedCS->get() : nullptr;
+ if (pCountedCS) {
auto* pPageData = document()->GetPageData();
- if (pPageData)
- pPageData->ReleaseColorSpace(pCS->GetArray());
+ if (pPageData) {
+ m_pCS.Release(); // Give up unowned reference first.
+ pPageData->ReleaseColorSpace(pCountedCS->GetArray());
+ }
}
}