summaryrefslogtreecommitdiff
path: root/core/src/fpdfapi/fpdf_page/fpdf_page_pattern.cpp
diff options
context:
space:
mode:
authorJun Fang <jun_fang@foxitsoftware.com>2014-08-05 02:38:22 -0700
committerJun Fang <jun_fang@foxitsoftware.com>2014-08-05 02:38:22 -0700
commit1b9c5c4dc41956b8c5ab17b9a882adf8a2513768 (patch)
tree5ec68ec6965397b29bfe174894c021618db4c42e /core/src/fpdfapi/fpdf_page/fpdf_page_pattern.cpp
parent06a8c8737b731d601af11cd9d61308c097cacc5f (diff)
downloadpdfium-1b9c5c4dc41956b8c5ab17b9a882adf8a2513768.tar.xz
The root cause of this issue is shown as below:
Patterns are managed in CPDF_DocPageData. When a document is closed, all patterns will be released in the deconstruction of CPDF_DocPageData. However, some patterns which are referenced in CPDF_Color can't get the notification from the destroy of CPDF_DocPageData. It will cause use-after-free in CPDF_Color::~CPDF_Color. BUG=392719 R=tsepez@chromium.org Review URL: https://codereview.chromium.org/439693002
Diffstat (limited to 'core/src/fpdfapi/fpdf_page/fpdf_page_pattern.cpp')
-rw-r--r--core/src/fpdfapi/fpdf_page/fpdf_page_pattern.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/core/src/fpdfapi/fpdf_page/fpdf_page_pattern.cpp b/core/src/fpdfapi/fpdf_page/fpdf_page_pattern.cpp
index 8cb6dc77dc..c7c1e7a565 100644
--- a/core/src/fpdfapi/fpdf_page/fpdf_page_pattern.cpp
+++ b/core/src/fpdfapi/fpdf_page/fpdf_page_pattern.cpp
@@ -6,6 +6,22 @@
#include "../../../include/fpdfapi/fpdf_page.h"
#include "pageint.h"
+
+CPDF_Pattern::CPDF_Pattern(const CFX_AffineMatrix* pParentMatrix) :
+ m_pPatternObj(NULL), m_PatternType(PATTERN_TILING), m_pDocument(NULL), m_pColor(NULL)
+{
+ if (pParentMatrix) {
+ m_ParentMatrix = *pParentMatrix;
+ }
+}
+
+CPDF_Pattern::~CPDF_Pattern()
+{
+ if (m_pColor) {
+ m_pColor->SetValue(NULL, NULL, 0);
+ m_pColor = NULL;
+ }
+}
CPDF_TilingPattern::CPDF_TilingPattern(CPDF_Document* pDoc, CPDF_Object* pPatternObj, const CFX_AffineMatrix* parentMatrix) :
CPDF_Pattern(parentMatrix)
{
@@ -25,6 +41,7 @@ CPDF_TilingPattern::~CPDF_TilingPattern()
{
if (m_pForm) {
delete m_pForm;
+ m_pForm = NULL;
}
}
FX_BOOL CPDF_TilingPattern::Load()