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

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

Issue 477323002: Font is used after release in CPDF_TextStateData::~CPDF_TextStateData (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 "../../../include/fpdfapi/fpdf_module.h" 8 #include "../../../include/fpdfapi/fpdf_module.h"
9 #include "../../../include/fdrm/fx_crypt.h" 9 #include "../../../include/fdrm/fx_crypt.h"
10 #include "../fpdf_font/font_int.h" 10 #include "../fpdf_font/font_int.h"
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 } 121 }
122 void CPDF_Document::RemoveColorSpaceFromPageData(CPDF_Object* pCSObj) 122 void CPDF_Document::RemoveColorSpaceFromPageData(CPDF_Object* pCSObj)
123 { 123 {
124 if (!pCSObj) { 124 if (!pCSObj) {
125 return; 125 return;
126 } 126 }
127 GetPageData()->ReleaseColorSpace(pCSObj); 127 GetPageData()->ReleaseColorSpace(pCSObj);
128 } 128 }
129 CPDF_DocPageData::CPDF_DocPageData(CPDF_Document *pPDFDoc) 129 CPDF_DocPageData::CPDF_DocPageData(CPDF_Document *pPDFDoc)
130 : m_pPDFDoc(pPDFDoc) 130 : m_pPDFDoc(pPDFDoc)
131 , m_bForceClear(FALSE)
Tom Sepez 2014/08/18 22:16:01 this should move down til after the m_FontFileMap
jun_fang 2014/08/18 22:59:31 Acknowledge.
131 , m_FontMap() 132 , m_FontMap()
132 , m_ColorSpaceMap() 133 , m_ColorSpaceMap()
133 , m_PatternMap() 134 , m_PatternMap()
134 , m_ImageMap() 135 , m_ImageMap()
135 , m_IccProfileMap() 136 , m_IccProfileMap()
136 , m_FontFileMap() 137 , m_FontFileMap()
137 { 138 {
138 m_FontMap.InitHashTable(64); 139 m_FontMap.InitHashTable(64);
139 m_ColorSpaceMap.InitHashTable(32); 140 m_ColorSpaceMap.InitHashTable(32);
140 m_PatternMap.InitHashTable(16); 141 m_PatternMap.InitHashTable(16);
141 m_ImageMap.InitHashTable(64); 142 m_ImageMap.InitHashTable(64);
142 m_IccProfileMap.InitHashTable(16); 143 m_IccProfileMap.InitHashTable(16);
143 m_FontFileMap.InitHashTable(32); 144 m_FontFileMap.InitHashTable(32);
144 } 145 }
145 CPDF_DocPageData::~CPDF_DocPageData() 146 CPDF_DocPageData::~CPDF_DocPageData()
146 { 147 {
147 Clear(FALSE); 148 Clear(FALSE);
149 m_bForceClear = TRUE;
Tom Sepez 2014/08/18 22:09:22 Let's move this down to Clear() itself. The first
jun_fang 2014/08/18 22:59:31 Good.
148 Clear(TRUE); 150 Clear(TRUE);
149 } 151 }
150 void CPDF_DocPageData::Clear(FX_BOOL bRelease) 152 void CPDF_DocPageData::Clear(FX_BOOL bRelease)
151 { 153 {
152 FX_POSITION pos; 154 FX_POSITION pos;
153 FX_DWORD nCount; 155 FX_DWORD nCount;
154 { 156 {
Tom Sepez 2014/08/18 22:09:22 nit: these braces don't do anything and can be re
155 pos = m_PatternMap.GetStartPosition(); 157 pos = m_PatternMap.GetStartPosition();
156 while (pos) { 158 while (pos) {
157 CPDF_Object* ptObj; 159 CPDF_Object* ptObj;
158 CPDF_CountedObject<CPDF_Pattern*>* ptData; 160 CPDF_CountedObject<CPDF_Pattern*>* ptData;
159 m_PatternMap.GetNextAssoc(pos, ptObj, ptData); 161 m_PatternMap.GetNextAssoc(pos, ptObj, ptData);
160 nCount = ptData->m_nCount; 162 nCount = ptData->m_nCount;
161 if (bRelease || nCount < 2) { 163 if (bRelease || nCount < 2) {
162 delete ptData->m_Obj; 164 delete ptData->m_Obj;
163 ptData->m_Obj = NULL; 165 ptData->m_Obj = NULL;
164 } 166 }
(...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after
637 m_FontFileMap.SetAt(pFontStream, ftData); 639 m_FontFileMap.SetAt(pFontStream, ftData);
638 return pFontFile; 640 return pFontFile;
639 } 641 }
640 void CPDF_DocPageData::ReleaseFontFileStreamAcc(CPDF_Stream* pFontStream, FX_BOO L bForce) 642 void CPDF_DocPageData::ReleaseFontFileStreamAcc(CPDF_Stream* pFontStream, FX_BOO L bForce)
641 { 643 {
642 if (!pFontStream) { 644 if (!pFontStream) {
643 return; 645 return;
644 } 646 }
645 PDF_DocPageData_Release<CPDF_Stream*, CPDF_StreamAcc*>(m_FontFileMap, pFontS tream, NULL, bForce); 647 PDF_DocPageData_Release<CPDF_Stream*, CPDF_StreamAcc*>(m_FontFileMap, pFontS tream, NULL, bForce);
646 } 648 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698