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; |
+ } |
+ } |
} |
} |
} |