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

Side by Side Diff: core/src/fxcodec/codec/fx_codec_jpeg.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_jbig.cpp ('k') | core/src/fxcrt/fx_basic_buffer.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 <setjmp.h> 7 #include <setjmp.h>
8 8
9 #include "../../../include/fxcodec/fx_codec.h" 9 #include "../../../include/fxcodec/fx_codec.h"
10 #include "../../../include/fxcrt/fx_safe_types.h" 10 #include "../../../include/fxcrt/fx_safe_types.h"
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 if (cinfo.next_scanline == row) { 214 if (cinfo.next_scanline == row) {
215 dest_buf = 215 dest_buf =
216 FX_Realloc(uint8_t, dest_buf, dest_buf_length + JPEG_BLOCK_SIZE); 216 FX_Realloc(uint8_t, dest_buf, dest_buf_length + JPEG_BLOCK_SIZE);
217 dest.next_output_byte = dest_buf + dest_buf_length - dest.free_in_buffer; 217 dest.next_output_byte = dest_buf + dest_buf_length - dest.free_in_buffer;
218 dest_buf_length += JPEG_BLOCK_SIZE; 218 dest_buf_length += JPEG_BLOCK_SIZE;
219 dest.free_in_buffer += JPEG_BLOCK_SIZE; 219 dest.free_in_buffer += JPEG_BLOCK_SIZE;
220 } 220 }
221 } 221 }
222 jpeg_finish_compress(&cinfo); 222 jpeg_finish_compress(&cinfo);
223 jpeg_destroy_compress(&cinfo); 223 jpeg_destroy_compress(&cinfo);
224 if (line_buf) { 224 FX_Free(line_buf);
225 FX_Free(line_buf);
226 }
227 dest_size = dest_buf_length - (FX_STRSIZE)dest.free_in_buffer; 225 dest_size = dest_buf_length - (FX_STRSIZE)dest.free_in_buffer;
228 } 226 }
229 static FX_BOOL _JpegLoadInfo(const uint8_t* src_buf, 227 static FX_BOOL _JpegLoadInfo(const uint8_t* src_buf,
230 FX_DWORD src_size, 228 FX_DWORD src_size,
231 int& width, 229 int& width,
232 int& height, 230 int& height,
233 int& num_components, 231 int& num_components,
234 int& bits_per_components, 232 int& bits_per_components,
235 FX_BOOL& color_transform, 233 FX_BOOL& color_transform,
236 uint8_t** icc_buf_ptr, 234 uint8_t** icc_buf_ptr,
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 FXSYS_memset(&cinfo, 0, sizeof(cinfo)); 336 FXSYS_memset(&cinfo, 0, sizeof(cinfo));
339 FXSYS_memset(&jerr, 0, sizeof(jerr)); 337 FXSYS_memset(&jerr, 0, sizeof(jerr));
340 FXSYS_memset(&src, 0, sizeof(src)); 338 FXSYS_memset(&src, 0, sizeof(src));
341 m_nDefaultScaleDenom = 1; 339 m_nDefaultScaleDenom = 1;
342 } 340 }
343 CCodec_JpegDecoder::~CCodec_JpegDecoder() { 341 CCodec_JpegDecoder::~CCodec_JpegDecoder() {
344 if (m_pExtProvider) { 342 if (m_pExtProvider) {
345 m_pExtProvider->DestroyDecoder(m_pExtContext); 343 m_pExtProvider->DestroyDecoder(m_pExtContext);
346 return; 344 return;
347 } 345 }
348 if (m_pScanlineBuf) { 346 FX_Free(m_pScanlineBuf);
349 FX_Free(m_pScanlineBuf);
350 }
351 if (m_bInited) { 347 if (m_bInited) {
352 jpeg_destroy_decompress(&cinfo); 348 jpeg_destroy_decompress(&cinfo);
353 } 349 }
354 } 350 }
355 FX_BOOL CCodec_JpegDecoder::InitDecode() { 351 FX_BOOL CCodec_JpegDecoder::InitDecode() {
356 cinfo.err = &jerr; 352 cinfo.err = &jerr;
357 cinfo.client_data = &m_JmpBuf; 353 cinfo.client_data = &m_JmpBuf;
358 if (setjmp(m_JmpBuf) == -1) { 354 if (setjmp(m_JmpBuf) == -1) {
359 return FALSE; 355 return FALSE;
360 } 356 }
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after
712 } 708 }
713 if (avail_buf_ptr != NULL) { 709 if (avail_buf_ptr != NULL) {
714 *avail_buf_ptr = NULL; 710 *avail_buf_ptr = NULL;
715 if (((FXJPEG_Context*)pContext)->m_SrcMgr.bytes_in_buffer > 0) { 711 if (((FXJPEG_Context*)pContext)->m_SrcMgr.bytes_in_buffer > 0) {
716 *avail_buf_ptr = 712 *avail_buf_ptr =
717 (uint8_t*)((FXJPEG_Context*)pContext)->m_SrcMgr.next_input_byte; 713 (uint8_t*)((FXJPEG_Context*)pContext)->m_SrcMgr.next_input_byte;
718 } 714 }
719 } 715 }
720 return (FX_DWORD)((FXJPEG_Context*)pContext)->m_SrcMgr.bytes_in_buffer; 716 return (FX_DWORD)((FXJPEG_Context*)pContext)->m_SrcMgr.bytes_in_buffer;
721 } 717 }
OLDNEW
« no previous file with comments | « core/src/fxcodec/codec/fx_codec_jbig.cpp ('k') | core/src/fxcrt/fx_basic_buffer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698