diff options
author | Tom Sepez <tsepez@chromium.org> | 2017-05-26 11:25:06 -0700 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-05-26 19:16:38 +0000 |
commit | fb9c11b49ee4fe6c18703d661dcaee498085c4c5 (patch) | |
tree | 026f0d4df7b09ef52f485de663dbbc20239100fe /core/fpdfapi/page | |
parent | f1697fa06b9fae75dd1c0782f5a721795cfc4a0c (diff) | |
download | pdfium-fb9c11b49ee4fe6c18703d661dcaee498085c4c5.tar.xz |
Release unowned CS reference before maybe destroying owned one
Colorspaces need to be properly refcounted but in the mean time,
get rid of an obvious dangling pointer.
Bug: 726728
Change-Id: I6bd879b18f61f7f5defd2679ce896013eb218b9b
Reviewed-on: https://pdfium-review.googlesource.com/6072
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'core/fpdfapi/page')
-rw-r--r-- | core/fpdfapi/page/cpdf_shadingpattern.cpp | 10 |
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()); + } } } |