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

Side by Side Diff: core/src/fxcodec/jbig2/JBig2_SymbolDict.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 unified diff | Download patch
« no previous file with comments | « core/src/fxcodec/jbig2/JBig2_SymbolDict.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #include "JBig2_SymbolDict.h" 7 #include "JBig2_SymbolDict.h"
8 8
9 #include "../../../include/fxcrt/fx_memory.h" 9 #include "../../../include/fxcrt/fx_memory.h"
10 #include "JBig2_Image.h"
10 11
11 CJBig2_SymbolDict::CJBig2_SymbolDict() { 12 CJBig2_SymbolDict::CJBig2_SymbolDict() {
12 SDNUMEXSYMS = 0; 13 SDNUMEXSYMS = 0;
13 SDEXSYMS = NULL; 14 SDEXSYMS = NULL;
14 m_bContextRetained = FALSE; 15 m_bContextRetained = FALSE;
15 m_gbContext = m_grContext = NULL; 16 m_gbContext = m_grContext = NULL;
16 } 17 }
17 18
18 CJBig2_SymbolDict* CJBig2_SymbolDict::DeepCopy() { 19 nonstd::unique_ptr<CJBig2_SymbolDict> CJBig2_SymbolDict::DeepCopy() const {
19 CJBig2_SymbolDict* src = this; 20 nonstd::unique_ptr<CJBig2_SymbolDict> dst;
20 if (src->m_bContextRetained || src->m_gbContext || src->m_grContext) { 21 const CJBig2_SymbolDict* src = this;
21 return NULL; 22 if (src->m_bContextRetained || src->m_gbContext || src->m_grContext)
22 } 23 return dst;
23 CJBig2_SymbolDict* dst = new CJBig2_SymbolDict; 24
25 dst.reset(new CJBig2_SymbolDict);
24 dst->SDNUMEXSYMS = src->SDNUMEXSYMS; 26 dst->SDNUMEXSYMS = src->SDNUMEXSYMS;
25 dst->SDEXSYMS = FX_Alloc(CJBig2_Image*, src->SDNUMEXSYMS); 27 dst->SDEXSYMS = FX_Alloc(CJBig2_Image*, src->SDNUMEXSYMS);
26 for (FX_DWORD i = 0; i < src->SDNUMEXSYMS; i++) { 28 for (FX_DWORD i = 0; i < src->SDNUMEXSYMS; ++i) {
27 if (src->SDEXSYMS[i]) { 29 if (src->SDEXSYMS[i]) {
28 dst->SDEXSYMS[i] = new CJBig2_Image(*(src->SDEXSYMS[i])); 30 dst->SDEXSYMS[i] = new CJBig2_Image(*(src->SDEXSYMS[i]));
29 } else { 31 } else {
30 dst->SDEXSYMS[i] = NULL; 32 dst->SDEXSYMS[i] = NULL;
31 } 33 }
32 } 34 }
33 return dst; 35 return dst;
34 } 36 }
35 37
36 CJBig2_SymbolDict::~CJBig2_SymbolDict() { 38 CJBig2_SymbolDict::~CJBig2_SymbolDict() {
37 if (SDEXSYMS) { 39 if (SDEXSYMS) {
38 for (FX_DWORD i = 0; i < SDNUMEXSYMS; i++) { 40 for (FX_DWORD i = 0; i < SDNUMEXSYMS; i++) {
39 delete SDEXSYMS[i]; 41 delete SDEXSYMS[i];
40 } 42 }
41 FX_Free(SDEXSYMS); 43 FX_Free(SDEXSYMS);
42 } 44 }
43 if (m_bContextRetained) { 45 if (m_bContextRetained) {
44 FX_Free(m_gbContext); 46 FX_Free(m_gbContext);
45 FX_Free(m_grContext); 47 FX_Free(m_grContext);
46 } 48 }
47 } 49 }
OLDNEW
« no previous file with comments | « core/src/fxcodec/jbig2/JBig2_SymbolDict.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698