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

Side by Side Diff: core/src/fxcodec/jbig2/JBig2_SymbolDict.cpp

Issue 837093002: Check for NULL pointers in CJBig2_SymbolDict::DeepCopy(). (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 5 years, 11 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 | « no previous file | 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 CJBig2_SymbolDict::CJBig2_SymbolDict() 8 CJBig2_SymbolDict::CJBig2_SymbolDict()
9 { 9 {
10 SDNUMEXSYMS = 0; 10 SDNUMEXSYMS = 0;
11 SDEXSYMS = NULL; 11 SDEXSYMS = NULL;
12 m_bContextRetained = FALSE; 12 m_bContextRetained = FALSE;
13 m_gbContext = m_grContext = NULL; 13 m_gbContext = m_grContext = NULL;
14 } 14 }
15 15
16 CJBig2_SymbolDict *CJBig2_SymbolDict::DeepCopy() 16 CJBig2_SymbolDict *CJBig2_SymbolDict::DeepCopy()
17 { 17 {
18 CJBig2_SymbolDict *dst = NULL; 18 CJBig2_SymbolDict *dst = NULL;
19 CJBig2_SymbolDict *src = this; 19 CJBig2_SymbolDict *src = this;
20 if (src->m_bContextRetained || 20 if (src->m_bContextRetained ||
21 src->m_gbContext || 21 src->m_gbContext ||
22 src->m_grContext) { 22 src->m_grContext) {
23 return NULL; 23 return NULL;
24 } 24 }
25 JBIG2_ALLOC(dst, CJBig2_SymbolDict()); 25 JBIG2_ALLOC(dst, CJBig2_SymbolDict());
26 dst->SDNUMEXSYMS = src->SDNUMEXSYMS; 26 dst->SDNUMEXSYMS = src->SDNUMEXSYMS;
27 dst->SDEXSYMS = (CJBig2_Image**)m_pModule->JBig2_Malloc2( 27 dst->SDEXSYMS = (CJBig2_Image**)m_pModule->JBig2_Malloc2(
28 sizeof(CJBig2_Image*), src->SDNUMEXSYMS); 28 sizeof(CJBig2_Image*), src->SDNUMEXSYMS);
29 for(FX_DWORD i = 0; i < src->SDNUMEXSYMS; i++) { 29 for(FX_DWORD i = 0; i < src->SDNUMEXSYMS; i++) {
30 JBIG2_ALLOC(dst->SDEXSYMS[i], 30 if (src->SDEXSYMS[i]) {
31 CJBig2_Image(*(src->SDEXSYMS[i]))); 31 JBIG2_ALLOC(dst->SDEXSYMS[i],
32 CJBig2_Image(*(src->SDEXSYMS[i])));
33 } else {
34 dst->SDEXSYMS[i] = NULL;
35 }
32 } 36 }
33 return dst; 37 return dst;
34 } 38 }
35 39
36 CJBig2_SymbolDict::~CJBig2_SymbolDict() 40 CJBig2_SymbolDict::~CJBig2_SymbolDict()
37 { 41 {
38 if(SDEXSYMS) { 42 if(SDEXSYMS) {
39 for(FX_DWORD i = 0; i < SDNUMEXSYMS; i++) { 43 for(FX_DWORD i = 0; i < SDNUMEXSYMS; i++) {
40 if(SDEXSYMS[i]) { 44 if(SDEXSYMS[i]) {
41 delete SDEXSYMS[i]; 45 delete SDEXSYMS[i];
42 } 46 }
43 } 47 }
44 m_pModule->JBig2_Free(SDEXSYMS); 48 m_pModule->JBig2_Free(SDEXSYMS);
45 } 49 }
46 if(m_bContextRetained) { 50 if(m_bContextRetained) {
47 if(m_gbContext) { 51 if(m_gbContext) {
48 m_pModule->JBig2_Free(m_gbContext); 52 m_pModule->JBig2_Free(m_gbContext);
49 } 53 }
50 if(m_grContext) { 54 if(m_grContext) {
51 m_pModule->JBig2_Free(m_grContext); 55 m_pModule->JBig2_Free(m_grContext);
52 } 56 }
53 } 57 }
54 } 58 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698