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

Unified 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: core/src/fpdfapi/fpdf_page/fpdf_page_graph_state.cpp
diff --git a/core/src/fpdfapi/fpdf_page/fpdf_page_graph_state.cpp b/core/src/fpdfapi/fpdf_page/fpdf_page_graph_state.cpp
index 8053718c190fef0413ae94c8a1857a2a30f136ca..99bb5b89cd03b14640286bce705ec0a2d2f4fbe7 100644
--- a/core/src/fpdfapi/fpdf_page/fpdf_page_graph_state.cpp
+++ b/core/src/fpdfapi/fpdf_page/fpdf_page_graph_state.cpp
@@ -285,6 +285,7 @@ void CPDF_ColorState::SetStrokePattern(CPDF_Pattern* pPattern, FX_FLOAT* pValue,
CPDF_TextStateData::CPDF_TextStateData()
{
m_pFont = NULL;
+ m_pDocument = NULL;
m_FontSize = 1.0f;
m_WordSpace = 0;
m_CharSpace = 0;
@@ -296,27 +297,35 @@ CPDF_TextStateData::CPDF_TextStateData()
}
CPDF_TextStateData::CPDF_TextStateData(const CPDF_TextStateData& src)
{
+ if (this == &src) {
+ return;
+ }
FXSYS_memcpy32(this, &src, sizeof(CPDF_TextStateData));
- if (m_pFont && m_pFont->m_pDocument) {
- m_pFont = m_pFont->m_pDocument->GetPageData()->GetFont(m_pFont->GetFontDict(), FALSE);
+ if (m_pDocument && m_pFont) {
+ m_pFont = m_pDocument->GetPageData()->GetFont(m_pFont->GetFontDict(), FALSE);
}
}
CPDF_TextStateData::~CPDF_TextStateData()
{
- CPDF_Font* pFont = m_pFont;
- if (pFont && pFont->m_pDocument) {
- pFont->m_pDocument->GetPageData()->ReleaseFont(pFont->GetFontDict());
+ if (m_pDocument && m_pFont) {
+ CPDF_DocPageData *pPageData = m_pDocument->GetPageData();
+ if (pPageData && !pPageData->IsForceClear()) {
+ pPageData->ReleaseFont(m_pFont->GetFontDict());
+ }
}
}
void CPDF_TextState::SetFont(CPDF_Font* pFont)
{
- CPDF_Font*& pStateFont = GetModify()->m_pFont;
- CPDF_DocPageData* pDocPageData = NULL;
- if (pStateFont && pStateFont->m_pDocument) {
- pDocPageData = pStateFont->m_pDocument->GetPageData();
- pDocPageData->ReleaseFont(pStateFont->GetFontDict());
+ CPDF_TextStateData* pStateData = GetModify();
+ if (pStateData) {
+ CPDF_Document* pDoc = pStateData->m_pDocument;
+ CPDF_DocPageData *pPageData = pDoc ? pDoc->GetPageData() : NULL;
+ if (pPageData && pStateData->m_pFont && !pPageData->IsForceClear()) {
+ pPageData->ReleaseFont(pStateData->m_pFont->GetFontDict());
+ }
+ pStateData->m_pDocument = pFont ? pFont->m_pDocument : NULL;
+ pStateData->m_pFont = pFont;
}
- pStateFont = pFont;
}
FX_FLOAT CPDF_TextState::GetFontSizeV() const
{
« 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