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

Unified Diff: core/src/fxcodec/jbig2/JBig2_Context.cpp

Issue 1374633004: Disable JBIG2 cache; prevent data corruption - try 2. (Closed) Base URL: https://pdfium.googlesource.com/pdfium@master
Patch Set: nit Created 5 years, 2 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 | core/src/fxcodec/jbig2/JBig2_SymbolDict.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: core/src/fxcodec/jbig2/JBig2_Context.cpp
diff --git a/core/src/fxcodec/jbig2/JBig2_Context.cpp b/core/src/fxcodec/jbig2/JBig2_Context.cpp
index f2c44b726aeb8562d00395ecf3ef7b05d6b3f019..ca895e5b9c0378fd4985c2d8493c658bb248b228 100644
--- a/core/src/fxcodec/jbig2/JBig2_Context.cpp
+++ b/core/src/fxcodec/jbig2/JBig2_Context.cpp
@@ -25,7 +25,10 @@
//
// Disabled until we can figure out how to clear cache between documents.
// https://code.google.com/p/pdfium/issues/detail?id=207
+#define DISABLE_SYMBOL_CACHE
+#ifndef DISABLE_SYMBOL_CACHE
static const int kSymbolDictCacheMaxSize = 2;
+#endif
CJBig2_Context* CJBig2_Context::CreateContext(
const uint8_t* pGlobalData,
@@ -623,7 +626,8 @@ int32_t CJBig2_Context::parseSymbolDict(CJBig2_Segment* pSegment,
for (std::list<CJBig2_CachePair>::iterator it = m_pSymbolDictCache->begin();
it != m_pSymbolDictCache->end(); ++it) {
if (it->first == key) {
- pSegment->m_Result.sd = it->second->DeepCopy();
+ nonstd::unique_ptr<CJBig2_SymbolDict> copy(it->second->DeepCopy());
+ pSegment->m_Result.sd = copy.release();
m_pSymbolDictCache->push_front(*it);
m_pSymbolDictCache->erase(it);
cache_hit = true;
@@ -651,14 +655,17 @@ int32_t CJBig2_Context::parseSymbolDict(CJBig2_Segment* pSegment,
}
m_pStream->alignByte();
}
- CJBig2_SymbolDict* value = pSegment->m_Result.sd->DeepCopy();
+#ifndef DISABLE_SYMBOL_CACHE
+ nonstd::unique_ptr<CJBig2_SymbolDict> value =
+ pSegment->m_Result.sd->DeepCopy();
if (value && kSymbolDictCacheMaxSize > 0) {
while (m_pSymbolDictCache->size() >= kSymbolDictCacheMaxSize) {
delete m_pSymbolDictCache->back().second;
m_pSymbolDictCache->pop_back();
}
- m_pSymbolDictCache->push_front(CJBig2_CachePair(key, value));
+ m_pSymbolDictCache->push_front(CJBig2_CachePair(key, value.release()));
}
+#endif
}
if (wFlags & 0x0200) {
pSegment->m_Result.sd->m_bContextRetained = TRUE;
« no previous file with comments | « no previous file | core/src/fxcodec/jbig2/JBig2_SymbolDict.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698