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

Side by Side Diff: core/src/fpdfapi/fpdf_page/fpdf_page_graph_state.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
« no previous file with comments | « core/src/fpdfapi/fpdf_page/fpdf_page_doc.cpp ('k') | core/src/fpdfapi/fpdf_page/pageint.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_pageobj.h" 8 #include "../../../include/fpdfapi/fpdf_pageobj.h"
9 #include "../../../include/fpdfapi/fpdf_module.h" 9 #include "../../../include/fpdfapi/fpdf_module.h"
10 #include "../../../include/fpdfapi/fpdf_render.h" 10 #include "../../../include/fpdfapi/fpdf_render.h"
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 FX_BOOL ret = pData->m_StrokeColor.GetRGB(R, G, B); 278 FX_BOOL ret = pData->m_StrokeColor.GetRGB(R, G, B);
279 if (pPattern->m_PatternType == 1 && ((CPDF_TilingPattern*)pPattern)->m_bColo red && !ret) { 279 if (pPattern->m_PatternType == 1 && ((CPDF_TilingPattern*)pPattern)->m_bColo red && !ret) {
280 pData->m_StrokeRGB = 0x00BFBFBF; 280 pData->m_StrokeRGB = 0x00BFBFBF;
281 return; 281 return;
282 } 282 }
283 pData->m_StrokeRGB = pData->m_StrokeColor.GetRGB(R, G, B) ? FXSYS_RGB(R, G, B) : (FX_DWORD) - 1; 283 pData->m_StrokeRGB = pData->m_StrokeColor.GetRGB(R, G, B) ? FXSYS_RGB(R, G, B) : (FX_DWORD) - 1;
284 } 284 }
285 CPDF_TextStateData::CPDF_TextStateData() 285 CPDF_TextStateData::CPDF_TextStateData()
286 { 286 {
287 m_pFont = NULL; 287 m_pFont = NULL;
288 m_pDocument = NULL;
288 m_FontSize = 1.0f; 289 m_FontSize = 1.0f;
289 m_WordSpace = 0; 290 m_WordSpace = 0;
290 m_CharSpace = 0; 291 m_CharSpace = 0;
291 m_TextMode = 0; 292 m_TextMode = 0;
292 m_Matrix[0] = m_Matrix[3] = 1.0f; 293 m_Matrix[0] = m_Matrix[3] = 1.0f;
293 m_Matrix[1] = m_Matrix[2] = 0; 294 m_Matrix[1] = m_Matrix[2] = 0;
294 m_CTM[0] = m_CTM[3] = 1.0f; 295 m_CTM[0] = m_CTM[3] = 1.0f;
295 m_CTM[1] = m_CTM[2] = 0; 296 m_CTM[1] = m_CTM[2] = 0;
296 } 297 }
297 CPDF_TextStateData::CPDF_TextStateData(const CPDF_TextStateData& src) 298 CPDF_TextStateData::CPDF_TextStateData(const CPDF_TextStateData& src)
298 { 299 {
300 if (this == &src) {
301 return;
302 }
299 FXSYS_memcpy32(this, &src, sizeof(CPDF_TextStateData)); 303 FXSYS_memcpy32(this, &src, sizeof(CPDF_TextStateData));
300 if (m_pFont && m_pFont->m_pDocument) { 304 if (m_pDocument && m_pFont) {
301 m_pFont = m_pFont->m_pDocument->GetPageData()->GetFont(m_pFont->GetFontD ict(), FALSE); 305 m_pFont = m_pDocument->GetPageData()->GetFont(m_pFont->GetFontDict(), FA LSE);
302 } 306 }
303 } 307 }
304 CPDF_TextStateData::~CPDF_TextStateData() 308 CPDF_TextStateData::~CPDF_TextStateData()
305 { 309 {
306 CPDF_Font* pFont = m_pFont; 310 if (m_pDocument && m_pFont) {
307 if (pFont && pFont->m_pDocument) { 311 CPDF_DocPageData *pPageData = m_pDocument->GetPageData();
308 pFont->m_pDocument->GetPageData()->ReleaseFont(pFont->GetFontDict()); 312 if (pPageData && !pPageData->IsForceClear()) {
313 pPageData->ReleaseFont(m_pFont->GetFontDict());
314 }
309 } 315 }
310 } 316 }
311 void CPDF_TextState::SetFont(CPDF_Font* pFont) 317 void CPDF_TextState::SetFont(CPDF_Font* pFont)
312 { 318 {
313 CPDF_Font*& pStateFont = GetModify()->m_pFont; 319 CPDF_TextStateData* pStateData = GetModify();
314 CPDF_DocPageData* pDocPageData = NULL; 320 if (pStateData) {
315 if (pStateFont && pStateFont->m_pDocument) { 321 CPDF_Document* pDoc = pStateData->m_pDocument;
316 pDocPageData = pStateFont->m_pDocument->GetPageData(); 322 CPDF_DocPageData *pPageData = pDoc ? pDoc->GetPageData() : NULL;
317 pDocPageData->ReleaseFont(pStateFont->GetFontDict()); 323 if (pPageData && pStateData->m_pFont && !pPageData->IsForceClear()) {
324 pPageData->ReleaseFont(pStateData->m_pFont->GetFontDict());
325 }
326 pStateData->m_pDocument = pFont ? pFont->m_pDocument : NULL;
327 pStateData->m_pFont = pFont;
318 } 328 }
319 pStateFont = pFont;
320 } 329 }
321 FX_FLOAT CPDF_TextState::GetFontSizeV() const 330 FX_FLOAT CPDF_TextState::GetFontSizeV() const
322 { 331 {
323 FX_FLOAT* pMatrix = GetMatrix(); 332 FX_FLOAT* pMatrix = GetMatrix();
324 FX_FLOAT unit = FXSYS_sqrt2(pMatrix[1], pMatrix[3]); 333 FX_FLOAT unit = FXSYS_sqrt2(pMatrix[1], pMatrix[3]);
325 FX_FLOAT size = FXSYS_Mul(unit, GetFontSize()); 334 FX_FLOAT size = FXSYS_Mul(unit, GetFontSize());
326 return (FX_FLOAT)FXSYS_fabs(size); 335 return (FX_FLOAT)FXSYS_fabs(size);
327 } 336 }
328 FX_FLOAT CPDF_TextState::GetFontSizeH() const 337 FX_FLOAT CPDF_TextState::GetFontSizeH() const
329 { 338 {
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after
698 pDict = NULL; 707 pDict = NULL;
699 if (item.GetParamType() == CPDF_ContentMarkItem::PropertiesDict || 708 if (item.GetParamType() == CPDF_ContentMarkItem::PropertiesDict ||
700 item.GetParamType() == CPDF_ContentMarkItem::DirectDict) { 709 item.GetParamType() == CPDF_ContentMarkItem::DirectDict) {
701 pDict = (CPDF_Dictionary*)item.GetParam(); 710 pDict = (CPDF_Dictionary*)item.GetParam();
702 } 711 }
703 return TRUE; 712 return TRUE;
704 } 713 }
705 } 714 }
706 return FALSE; 715 return FALSE;
707 } 716 }
OLDNEW
« no previous file with comments | « core/src/fpdfapi/fpdf_page/fpdf_page_doc.cpp ('k') | core/src/fpdfapi/fpdf_page/pageint.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698