diff options
author | Lei Zhang <thestig@chromium.org> | 2015-10-09 13:57:36 -0700 |
---|---|---|
committer | Lei Zhang <thestig@chromium.org> | 2015-10-09 13:57:36 -0700 |
commit | 5428555d7bca8116fa8c6d6914674f2c2adb17ac (patch) | |
tree | f8217f4229aa6eecc33134a0c8ab9013b20e7fc6 /core/src/fxcodec/jbig2/JBig2_SymbolDict.cpp | |
parent | e7bd5081be68feb4978659a0c18090314ff44d09 (diff) | |
download | pdfium-5428555d7bca8116fa8c6d6914674f2c2adb17ac.tar.xz |
Merge to XFA: Sanitize CJBig2_SymbolDict's memory usage.
- Use std::vector<JBig2ArithCtx> instead of storing pointers to arrays.
- Make CJBig2_SymbolDict's members private with accessors.
- Use std::vector<JBig2ArithCtx> in related places.
- Steal Chromium's vector_as_array() and use it as an adaptor as needed.
BUG=514891
TBR=tsepez@chromium.org
Review URL: https://codereview.chromium.org/1388203003 .
(cherry picked from commit 3acb1ef909a22368507ed13817c4988c818e3aee)
Review URL: https://codereview.chromium.org/1401533004 .
Diffstat (limited to 'core/src/fxcodec/jbig2/JBig2_SymbolDict.cpp')
-rw-r--r-- | core/src/fxcodec/jbig2/JBig2_SymbolDict.cpp | 14 |
1 files changed, 3 insertions, 11 deletions
diff --git a/core/src/fxcodec/jbig2/JBig2_SymbolDict.cpp b/core/src/fxcodec/jbig2/JBig2_SymbolDict.cpp index a8f8a94529..351a8389c8 100644 --- a/core/src/fxcodec/jbig2/JBig2_SymbolDict.cpp +++ b/core/src/fxcodec/jbig2/JBig2_SymbolDict.cpp @@ -10,27 +10,19 @@ #include "JBig2_Image.h" CJBig2_SymbolDict::CJBig2_SymbolDict() { - m_bContextRetained = FALSE; - m_gbContext = m_grContext = NULL; } CJBig2_SymbolDict::~CJBig2_SymbolDict() { - if (m_bContextRetained) { - FX_Free(m_gbContext); - FX_Free(m_grContext); - } } nonstd::unique_ptr<CJBig2_SymbolDict> CJBig2_SymbolDict::DeepCopy() const { - nonstd::unique_ptr<CJBig2_SymbolDict> dst; const CJBig2_SymbolDict* src = this; - if (src->m_bContextRetained || src->m_gbContext || src->m_grContext) - return dst; - - dst.reset(new CJBig2_SymbolDict); + nonstd::unique_ptr<CJBig2_SymbolDict> dst(new CJBig2_SymbolDict); for (size_t i = 0; i < src->m_SDEXSYMS.size(); ++i) { CJBig2_Image* image = src->m_SDEXSYMS.get(i); dst->m_SDEXSYMS.push_back(image ? new CJBig2_Image(*image) : nullptr); } + dst->m_gbContext = src->m_gbContext; + dst->m_grContext = src->m_grContext; return dst; } |