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

Unified Diff: core/src/fpdfapi/fpdf_page/fpdf_page_doc.cpp

Issue 472653002: No need to release m_pBaseCS in CPDF_IndexedCS and CPDF_PatternCS (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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: core/src/fpdfapi/fpdf_page/fpdf_page_doc.cpp
diff --git a/core/src/fpdfapi/fpdf_page/fpdf_page_doc.cpp b/core/src/fpdfapi/fpdf_page/fpdf_page_doc.cpp
index 097bd61e6c5b1cf6827f9abc5cfd060cf9912380..8347f137f28dfb565c61fa422445c41c840e4417 100644
--- a/core/src/fpdfapi/fpdf_page/fpdf_page_doc.cpp
+++ b/core/src/fpdfapi/fpdf_page/fpdf_page_doc.cpp
@@ -192,15 +192,21 @@ void CPDF_DocPageData::Clear(FX_BOOL bRelease)
}
}
{
- pos = m_ColorSpaceMap.GetStartPosition();
- while (pos) {
- CPDF_Object* csKey;
- CPDF_CountedObject<CPDF_ColorSpace*>* csData;
- m_ColorSpaceMap.GetNextAssoc(pos, csKey, csData);
- nCount = csData->m_nCount;
- if (bRelease || nCount < 2) {
- csData->m_Obj->ReleaseCS();
- csData->m_Obj = NULL;
+ FX_POSITION pos_start = m_ColorSpaceMap.GetStartPosition();
Tom Sepez 2014/08/15 18:54:44 nit: I'd unroll the loop rather than trying to be
+ for (int releaseLoop = 0; releaseLoop < 2; releaseLoop++){
+ pos = pos_start;
+ while (pos) {
+ CPDF_Object* csKey;
+ CPDF_CountedObject<CPDF_ColorSpace*>* csData;
+ m_ColorSpaceMap.GetNextAssoc(pos, csKey, csData);
+ nCount = csData->m_nCount;
+ if ((bRelease || nCount < 2) && csData->m_Obj) {
Tom Sepez 2014/08/15 18:58:48 What about csData's that dont have an m_Obj? Look
+ int CS_Family = csData->m_Obj->GetFamily();
+ if ((releaseLoop == 0 && CS_Family == PDFCS_INDEXED) || (releaseLoop == 1 && CS_Family != PDFCS_INDEXED)) {
+ csData->m_Obj->ReleaseCS();
+ csData->m_Obj = NULL;
+ }
+ }
}
}
}
« 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