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

Unified Diff: core/fpdfapi/render/fpdf_render.cpp

Issue 2501053002: Properly release caches in CPDF_DocRenderData (Closed)
Patch Set: Created 4 years, 1 month 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: core/fpdfapi/render/fpdf_render.cpp
diff --git a/core/fpdfapi/render/fpdf_render.cpp b/core/fpdfapi/render/fpdf_render.cpp
index a431aa94864a9cc13d9dd40fc703e2d44ad6fb59..e4abb7e8329c1da3257731c8147864356f433d13 100644
--- a/core/fpdfapi/render/fpdf_render.cpp
+++ b/core/fpdfapi/render/fpdf_render.cpp
@@ -80,8 +80,14 @@ CPDF_Type3Cache* CPDF_DocRenderData::GetCachedType3(CPDF_Type3Font* pFont) {
void CPDF_DocRenderData::ReleaseCachedType3(CPDF_Type3Font* pFont) {
auto it = m_Type3FaceMap.find(pFont);
- if (it != m_Type3FaceMap.end())
+ if (it != m_Type3FaceMap.end()) {
it->second->RemoveRef();
+ if (it->second->use_count() < 2) {
+ delete it->second->get();
+ delete it->second;
+ m_Type3FaceMap.erase(it);
+ }
+ }
}
CPDF_RenderOptions::CPDF_RenderOptions()
@@ -1150,8 +1156,14 @@ CPDF_TransferFunc* CPDF_DocRenderData::GetTransferFunc(CPDF_Object* pObj) {
void CPDF_DocRenderData::ReleaseTransferFunc(CPDF_Object* pObj) {
auto it = m_TransferFuncMap.find(pObj);
- if (it != m_TransferFuncMap.end())
+ if (it != m_TransferFuncMap.end()) {
it->second->RemoveRef();
+ if (it->second->use_count() < 2) {
+ delete it->second->get();
+ delete it->second;
+ m_TransferFuncMap.erase(it);
+ }
+ }
}
CPDF_DeviceBuffer::CPDF_DeviceBuffer()
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698