summaryrefslogtreecommitdiff
path: root/core/src/fpdfapi/fpdf_page
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2015-08-17 16:26:03 -0700
committerTom Sepez <tsepez@chromium.org>2015-08-17 16:26:03 -0700
commitce4ffb8183af3fa2bb5133f0f7370a88e064c516 (patch)
tree16f05f79aed56678b45bea435addaa75fbb9f85f /core/src/fpdfapi/fpdf_page
parent52a48aadc19b2dee8abeb702269bb168eb6b6999 (diff)
downloadpdfium-ce4ffb8183af3fa2bb5133f0f7370a88e064c516.tar.xz
CFX_MapByteStringToPtr considered harmful.
R=thestig@chromium.org Review URL: https://codereview.chromium.org/1297723002 .
Diffstat (limited to 'core/src/fpdfapi/fpdf_page')
-rw-r--r--core/src/fpdfapi/fpdf_page/fpdf_page_doc.cpp21
-rw-r--r--core/src/fpdfapi/fpdf_page/pageint.h3
2 files changed, 9 insertions, 15 deletions
diff --git a/core/src/fpdfapi/fpdf_page/fpdf_page_doc.cpp b/core/src/fpdfapi/fpdf_page/fpdf_page_doc.cpp
index 74e33b56a9..210d5433be 100644
--- a/core/src/fpdfapi/fpdf_page/fpdf_page_doc.cpp
+++ b/core/src/fpdfapi/fpdf_page/fpdf_page_doc.cpp
@@ -171,14 +171,10 @@ void CPDF_DocPageData::Clear(FX_BOOL bForceRelease) {
continue;
if (bForceRelease || ipData->use_count() < 2) {
- CPDF_Stream* ipKey = curr_it->first;
- FX_POSITION pos2 = m_HashProfileMap.GetStartPosition();
- while (pos2) {
- CFX_ByteString bsKey;
- CPDF_Stream* pFindStream = nullptr;
- m_HashProfileMap.GetNextAssoc(pos2, bsKey, (void*&)pFindStream);
- if (ipKey == pFindStream) {
- m_HashProfileMap.RemoveKey(bsKey);
+ for (auto hash_it = m_HashProfileMap.begin();
+ hash_it != m_HashProfileMap.end(); ++hash_it) {
+ if (curr_it->first == hash_it->second) {
+ m_HashProfileMap.erase(hash_it);
break;
}
}
@@ -519,18 +515,17 @@ CPDF_IccProfile* CPDF_DocPageData::GetIccProfile(
CPDF_StreamAcc stream;
stream.LoadAllData(pIccProfileStream, FALSE);
uint8_t digest[20];
- CPDF_Stream* pCopiedStream = nullptr;
CRYPT_SHA1Generate(stream.GetData(), stream.GetSize(), digest);
- if (m_HashProfileMap.Lookup(CFX_ByteStringC(digest, 20),
- (void*&)pCopiedStream)) {
- auto it_copied_stream = m_IccProfileMap.find(pCopiedStream);
+ auto hash_it = m_HashProfileMap.find(CFX_ByteStringC(digest, 20));
+ if (hash_it != m_HashProfileMap.end()) {
+ auto it_copied_stream = m_IccProfileMap.find(hash_it->second);
return it_copied_stream->second->AddRef();
}
CPDF_IccProfile* pProfile =
new CPDF_IccProfile(stream.GetData(), stream.GetSize());
CPDF_CountedIccProfile* ipData = new CPDF_CountedIccProfile(pProfile);
m_IccProfileMap[pIccProfileStream] = ipData;
- m_HashProfileMap.SetAt(CFX_ByteStringC(digest, 20), pIccProfileStream);
+ m_HashProfileMap[CFX_ByteStringC(digest, 20)] = pIccProfileStream;
return ipData->AddRef();
}
diff --git a/core/src/fpdfapi/fpdf_page/pageint.h b/core/src/fpdfapi/fpdf_page/pageint.h
index bc03c3b5e6..6bec07268c 100644
--- a/core/src/fpdfapi/fpdf_page/pageint.h
+++ b/core/src/fpdfapi/fpdf_page/pageint.h
@@ -422,9 +422,8 @@ class CPDF_DocPageData {
using CPDF_PatternMap = std::map<CPDF_Object*, CPDF_CountedPattern*>;
CPDF_Document* const m_pPDFDoc;
- CFX_MapByteStringToPtr m_HashProfileMap;
FX_BOOL m_bForceClear;
-
+ std::map<CFX_ByteString, CPDF_Stream*> m_HashProfileMap;
CPDF_ColorSpaceMap m_ColorSpaceMap;
CPDF_FontFileMap m_FontFileMap;
CPDF_FontMap m_FontMap;