Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(56)

Side by Side Diff: core/src/fpdfapi/fpdf_page/fpdf_page_pattern.cpp

Issue 439693002: Fix use-after-free in CPDF_Color::~CPDF_Color (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #include "../../../include/fpdfapi/fpdf_page.h" 7 #include "../../../include/fpdfapi/fpdf_page.h"
8 #include "pageint.h" 8 #include "pageint.h"
9
10 CPDF_Pattern::~CPDF_Pattern()
11 {
12 if (m_pColor) {
13 m_pColor->SetValue(NULL, NULL, 0);
14 }
15 m_pColor = NULL;
Tom Sepez 2014/08/04 18:02:32 This can move inside the if {} since its already N
palmer 2014/08/04 18:17:11 Alternately, save a level of indentation: if (!m_
jun_fang 2014/08/04 18:37:11 Acknowledge
16 }
9 CPDF_TilingPattern::CPDF_TilingPattern(CPDF_Document* pDoc, CPDF_Object* pPatter nObj, const CFX_AffineMatrix* parentMatrix) : 17 CPDF_TilingPattern::CPDF_TilingPattern(CPDF_Document* pDoc, CPDF_Object* pPatter nObj, const CFX_AffineMatrix* parentMatrix) :
10 CPDF_Pattern(parentMatrix) 18 CPDF_Pattern(parentMatrix)
11 { 19 {
12 m_PatternType = PATTERN_TILING; 20 m_PatternType = PATTERN_TILING;
13 m_pPatternObj = pPatternObj; 21 m_pPatternObj = pPatternObj;
14 m_pDocument = pDoc; 22 m_pDocument = pDoc;
23 m_pColor = NULL;
15 CPDF_Dictionary* pDict = m_pPatternObj->GetDict(); 24 CPDF_Dictionary* pDict = m_pPatternObj->GetDict();
16 ASSERT(pDict != NULL); 25 ASSERT(pDict != NULL);
17 m_Pattern2Form = pDict->GetMatrix(FX_BSTRC("Matrix")); 26 m_Pattern2Form = pDict->GetMatrix(FX_BSTRC("Matrix"));
18 m_bColored = pDict->GetInteger(FX_BSTRC("PaintType")) == 1; 27 m_bColored = pDict->GetInteger(FX_BSTRC("PaintType")) == 1;
19 if (parentMatrix) { 28 if (parentMatrix) {
20 m_Pattern2Form.Concat(*parentMatrix); 29 m_Pattern2Form.Concat(*parentMatrix);
21 } 30 }
22 m_pForm = NULL; 31 m_pForm = NULL;
23 } 32 }
24 CPDF_TilingPattern::~CPDF_TilingPattern() 33 CPDF_TilingPattern::~CPDF_TilingPattern()
25 { 34 {
26 if (m_pForm) { 35 if (m_pForm) {
27 delete m_pForm; 36 delete m_pForm;
37 m_pForm = NULL;
28 } 38 }
29 } 39 }
30 FX_BOOL CPDF_TilingPattern::Load() 40 FX_BOOL CPDF_TilingPattern::Load()
31 { 41 {
32 if (m_pForm != NULL) { 42 if (m_pForm != NULL) {
33 return TRUE; 43 return TRUE;
34 } 44 }
35 CPDF_Dictionary* pDict = m_pPatternObj->GetDict(); 45 CPDF_Dictionary* pDict = m_pPatternObj->GetDict();
36 if (pDict == NULL) { 46 if (pDict == NULL) {
37 return FALSE; 47 return FALSE;
38 } 48 }
39 m_bColored = pDict->GetInteger(FX_BSTRC("PaintType")) == 1; 49 m_bColored = pDict->GetInteger(FX_BSTRC("PaintType")) == 1;
40 m_XStep = (FX_FLOAT)FXSYS_fabs(pDict->GetNumber(FX_BSTRC("XStep"))); 50 m_XStep = (FX_FLOAT)FXSYS_fabs(pDict->GetNumber(FX_BSTRC("XStep")));
41 m_YStep = (FX_FLOAT)FXSYS_fabs(pDict->GetNumber(FX_BSTRC("YStep"))); 51 m_YStep = (FX_FLOAT)FXSYS_fabs(pDict->GetNumber(FX_BSTRC("YStep")));
42 if (m_pPatternObj->GetType() != PDFOBJ_STREAM) { 52 if (m_pPatternObj->GetType() != PDFOBJ_STREAM) {
43 return FALSE; 53 return FALSE;
44 } 54 }
45 CPDF_Stream* pStream = (CPDF_Stream*)m_pPatternObj; 55 CPDF_Stream* pStream = (CPDF_Stream*)m_pPatternObj;
46 m_pForm = FX_NEW CPDF_Form(m_pDocument, NULL, pStream); 56 m_pForm = FX_NEW CPDF_Form(m_pDocument, NULL, pStream);
47 m_pForm->ParseContent(NULL, &m_ParentMatrix, NULL, NULL); 57 m_pForm->ParseContent(NULL, &m_ParentMatrix, NULL, NULL);
48 m_BBox = pDict->GetRect(FX_BSTRC("BBox")); 58 m_BBox = pDict->GetRect(FX_BSTRC("BBox"));
49 return TRUE; 59 return TRUE;
50 } 60 }
51 CPDF_ShadingPattern::CPDF_ShadingPattern(CPDF_Document* pDoc, CPDF_Object* pPatt ernObj, FX_BOOL bShading, const CFX_AffineMatrix* parentMatrix) : CPDF_Pattern(p arentMatrix) 61 CPDF_ShadingPattern::CPDF_ShadingPattern(CPDF_Document* pDoc, CPDF_Object* pPatt ernObj, FX_BOOL bShading, const CFX_AffineMatrix* parentMatrix) : CPDF_Pattern(p arentMatrix)
52 { 62 {
53 m_PatternType = PATTERN_SHADING; 63 m_PatternType = PATTERN_SHADING;
54 m_pPatternObj = bShading ? NULL : pPatternObj; 64 m_pPatternObj = bShading ? NULL : pPatternObj;
55 m_pDocument = pDoc; 65 m_pDocument = pDoc;
66 m_pColor = NULL;
56 m_bShadingObj = bShading; 67 m_bShadingObj = bShading;
57 if (!bShading) { 68 if (!bShading) {
58 CPDF_Dictionary* pDict = m_pPatternObj->GetDict(); 69 CPDF_Dictionary* pDict = m_pPatternObj->GetDict();
59 ASSERT(pDict != NULL); 70 ASSERT(pDict != NULL);
60 m_Pattern2Form = pDict->GetMatrix(FX_BSTRC("Matrix")); 71 m_Pattern2Form = pDict->GetMatrix(FX_BSTRC("Matrix"));
61 m_pShadingObj = pDict->GetElementValue(FX_BSTRC("Shading")); 72 m_pShadingObj = pDict->GetElementValue(FX_BSTRC("Shading"));
62 if (parentMatrix) { 73 if (parentMatrix) {
63 m_Pattern2Form.Concat(*parentMatrix); 74 m_Pattern2Form.Concat(*parentMatrix);
64 } 75 }
65 } else { 76 } else {
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 } 280 }
270 } 281 }
271 stream.m_BitStream.SkipBits(stream.m_nComps * stream.m_nCompBits * color _count); 282 stream.m_BitStream.SkipBits(stream.m_nComps * stream.m_nCompBits * color _count);
272 if (bGouraud) { 283 if (bGouraud) {
273 stream.m_BitStream.ByteAlign(); 284 stream.m_BitStream.ByteAlign();
274 } 285 }
275 } 286 }
276 rect.Transform(pMatrix); 287 rect.Transform(pMatrix);
277 return rect; 288 return rect;
278 } 289 }
OLDNEW
« core/include/fpdfapi/fpdf_resource.h ('K') | « core/src/fpdfapi/fpdf_page/fpdf_page_colors.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698