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

Side by Side Diff: core/src/fxcodec/codec/fx_codec_jbig.cpp

Issue 1297713003: Don't bother checking pointers before delete[] and FX_Free(). (Closed) Base URL: https://pdfium.googlesource.com/pdfium@master
Patch Set: rebase Created 5 years, 4 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/codec/fx_codec_icc.cpp ('k') | core/src/fxcodec/codec/fx_codec_jpeg.cpp » ('j') | 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 "../../../include/fxcodec/fx_codec.h" 7 #include "../../../include/fxcodec/fx_codec.h"
8 #include "codec_int.h" 8 #include "codec_int.h"
9 9
10 CCodec_Jbig2Context::CCodec_Jbig2Context() { 10 CCodec_Jbig2Context::CCodec_Jbig2Context() {
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 } 75 }
76 width = (FX_DWORD)dest_image->m_nWidth; 76 width = (FX_DWORD)dest_image->m_nWidth;
77 height = (FX_DWORD)dest_image->m_nHeight; 77 height = (FX_DWORD)dest_image->m_nHeight;
78 pitch = (FX_DWORD)dest_image->m_nStride; 78 pitch = (FX_DWORD)dest_image->m_nStride;
79 dest_buf = dest_image->m_pData; 79 dest_buf = dest_image->m_pData;
80 dest_image->m_bNeedFree = FALSE; 80 dest_image->m_bNeedFree = FALSE;
81 delete dest_image; 81 delete dest_image;
82 FX_Free(src_buf); 82 FX_Free(src_buf);
83 return TRUE; 83 return TRUE;
84 failed: 84 failed:
85 if (src_buf) { 85 FX_Free(src_buf);
86 FX_Free(src_buf);
87 }
88 return FALSE; 86 return FALSE;
89 } 87 }
90 FXCODEC_STATUS CCodec_Jbig2Module::StartDecode(void* pJbig2Context, 88 FXCODEC_STATUS CCodec_Jbig2Module::StartDecode(void* pJbig2Context,
91 FX_DWORD width, 89 FX_DWORD width,
92 FX_DWORD height, 90 FX_DWORD height,
93 const uint8_t* src_buf, 91 const uint8_t* src_buf,
94 FX_DWORD src_size, 92 FX_DWORD src_size,
95 const uint8_t* global_data, 93 const uint8_t* global_data,
96 FX_DWORD global_size, 94 FX_DWORD global_size,
97 uint8_t* dest_buf, 95 uint8_t* dest_buf,
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 } 179 }
182 width = (FX_DWORD)m_pJbig2Context->m_dest_image->m_nWidth; 180 width = (FX_DWORD)m_pJbig2Context->m_dest_image->m_nWidth;
183 height = (FX_DWORD)m_pJbig2Context->m_dest_image->m_nHeight; 181 height = (FX_DWORD)m_pJbig2Context->m_dest_image->m_nHeight;
184 pitch = (FX_DWORD)m_pJbig2Context->m_dest_image->m_nStride; 182 pitch = (FX_DWORD)m_pJbig2Context->m_dest_image->m_nStride;
185 dest_buf = m_pJbig2Context->m_dest_image->m_pData; 183 dest_buf = m_pJbig2Context->m_dest_image->m_pData;
186 m_pJbig2Context->m_dest_image->m_bNeedFree = FALSE; 184 m_pJbig2Context->m_dest_image->m_bNeedFree = FALSE;
187 delete m_pJbig2Context->m_dest_image; 185 delete m_pJbig2Context->m_dest_image;
188 FX_Free(m_pJbig2Context->m_src_buf); 186 FX_Free(m_pJbig2Context->m_src_buf);
189 return FXCODEC_STATUS_DECODE_FINISH; 187 return FXCODEC_STATUS_DECODE_FINISH;
190 failed: 188 failed:
191 if (m_pJbig2Context->m_src_buf) { 189 FX_Free(m_pJbig2Context->m_src_buf);
192 FX_Free(m_pJbig2Context->m_src_buf);
193 }
194 m_pJbig2Context->m_src_buf = NULL; 190 m_pJbig2Context->m_src_buf = NULL;
195 return FXCODEC_STATUS_ERROR; 191 return FXCODEC_STATUS_ERROR;
196 } 192 }
197 FXCODEC_STATUS CCodec_Jbig2Module::ContinueDecode(void* pJbig2Context, 193 FXCODEC_STATUS CCodec_Jbig2Module::ContinueDecode(void* pJbig2Context,
198 IFX_Pause* pPause) { 194 IFX_Pause* pPause) {
199 CCodec_Jbig2Context* m_pJbig2Context = (CCodec_Jbig2Context*)pJbig2Context; 195 CCodec_Jbig2Context* m_pJbig2Context = (CCodec_Jbig2Context*)pJbig2Context;
200 int ret = m_pJbig2Context->m_pContext->Continue(pPause); 196 int ret = m_pJbig2Context->m_pContext->Continue(pPause);
201 if (m_pJbig2Context->m_pContext->GetProcessiveStatus() != 197 if (m_pJbig2Context->m_pContext->GetProcessiveStatus() !=
202 FXCODEC_STATUS_DECODE_FINISH) { 198 FXCODEC_STATUS_DECODE_FINISH) {
203 return m_pJbig2Context->m_pContext->GetProcessiveStatus(); 199 return m_pJbig2Context->m_pContext->GetProcessiveStatus();
204 } 200 }
205 if (m_pJbig2Context->m_bFileReader) { 201 if (m_pJbig2Context->m_bFileReader) {
206 CJBig2_Context::DestroyContext(m_pJbig2Context->m_pContext); 202 CJBig2_Context::DestroyContext(m_pJbig2Context->m_pContext);
207 m_pJbig2Context->m_pContext = NULL; 203 m_pJbig2Context->m_pContext = NULL;
208 if (ret != JBIG2_SUCCESS) { 204 if (ret != JBIG2_SUCCESS) {
209 if (m_pJbig2Context->m_src_buf) { 205 FX_Free(m_pJbig2Context->m_src_buf);
210 FX_Free(m_pJbig2Context->m_src_buf);
211 }
212 m_pJbig2Context->m_src_buf = NULL; 206 m_pJbig2Context->m_src_buf = NULL;
213 return FXCODEC_STATUS_ERROR; 207 return FXCODEC_STATUS_ERROR;
214 } 208 }
215 delete m_pJbig2Context->m_dest_image; 209 delete m_pJbig2Context->m_dest_image;
216 FX_Free(m_pJbig2Context->m_src_buf); 210 FX_Free(m_pJbig2Context->m_src_buf);
217 return FXCODEC_STATUS_DECODE_FINISH; 211 return FXCODEC_STATUS_DECODE_FINISH;
218 } 212 }
219 CJBig2_Context::DestroyContext(m_pJbig2Context->m_pContext); 213 CJBig2_Context::DestroyContext(m_pJbig2Context->m_pContext);
220 m_pJbig2Context->m_pContext = NULL; 214 m_pJbig2Context->m_pContext = NULL;
221 if (ret != JBIG2_SUCCESS) { 215 if (ret != JBIG2_SUCCESS) {
222 return FXCODEC_STATUS_ERROR; 216 return FXCODEC_STATUS_ERROR;
223 } 217 }
224 int dword_size = 218 int dword_size =
225 m_pJbig2Context->m_height * m_pJbig2Context->m_dest_pitch / 4; 219 m_pJbig2Context->m_height * m_pJbig2Context->m_dest_pitch / 4;
226 FX_DWORD* dword_buf = (FX_DWORD*)m_pJbig2Context->m_dest_buf; 220 FX_DWORD* dword_buf = (FX_DWORD*)m_pJbig2Context->m_dest_buf;
227 for (int i = 0; i < dword_size; i++) { 221 for (int i = 0; i < dword_size; i++) {
228 dword_buf[i] = ~dword_buf[i]; 222 dword_buf[i] = ~dword_buf[i];
229 } 223 }
230 return FXCODEC_STATUS_DECODE_FINISH; 224 return FXCODEC_STATUS_DECODE_FINISH;
231 } 225 }
OLDNEW
« no previous file with comments | « core/src/fxcodec/codec/fx_codec_icc.cpp ('k') | core/src/fxcodec/codec/fx_codec_jpeg.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698