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

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: 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
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) {
225 FX_Free(line_buf); 224 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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 FXSYS_memset(&cinfo, 0, sizeof(cinfo)); 326 FXSYS_memset(&cinfo, 0, sizeof(cinfo));
329 FXSYS_memset(&jerr, 0, sizeof(jerr)); 327 FXSYS_memset(&jerr, 0, sizeof(jerr));
330 FXSYS_memset(&src, 0, sizeof(src)); 328 FXSYS_memset(&src, 0, sizeof(src));
331 m_nDefaultScaleDenom = 1; 329 m_nDefaultScaleDenom = 1;
332 } 330 }
333 CCodec_JpegDecoder::~CCodec_JpegDecoder() { 331 CCodec_JpegDecoder::~CCodec_JpegDecoder() {
334 if (m_pExtProvider) { 332 if (m_pExtProvider) {
335 m_pExtProvider->DestroyDecoder(m_pExtContext); 333 m_pExtProvider->DestroyDecoder(m_pExtContext);
336 return; 334 return;
337 } 335 }
338 if (m_pScanlineBuf) {
339 FX_Free(m_pScanlineBuf); 336 FX_Free(m_pScanlineBuf);
340 }
341 if (m_bInited) { 337 if (m_bInited) {
342 jpeg_destroy_decompress(&cinfo); 338 jpeg_destroy_decompress(&cinfo);
343 } 339 }
344 } 340 }
345 FX_BOOL CCodec_JpegDecoder::InitDecode() { 341 FX_BOOL CCodec_JpegDecoder::InitDecode() {
346 cinfo.err = &jerr; 342 cinfo.err = &jerr;
347 cinfo.client_data = &m_JmpBuf; 343 cinfo.client_data = &m_JmpBuf;
348 if (setjmp(m_JmpBuf) == -1) { 344 if (setjmp(m_JmpBuf) == -1) {
349 return FALSE; 345 return FALSE;
350 } 346 }
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after
702 } 698 }
703 if (avail_buf_ptr != NULL) { 699 if (avail_buf_ptr != NULL) {
704 *avail_buf_ptr = NULL; 700 *avail_buf_ptr = NULL;
705 if (((FXJPEG_Context*)pContext)->m_SrcMgr.bytes_in_buffer > 0) { 701 if (((FXJPEG_Context*)pContext)->m_SrcMgr.bytes_in_buffer > 0) {
706 *avail_buf_ptr = 702 *avail_buf_ptr =
707 (uint8_t*)((FXJPEG_Context*)pContext)->m_SrcMgr.next_input_byte; 703 (uint8_t*)((FXJPEG_Context*)pContext)->m_SrcMgr.next_input_byte;
708 } 704 }
709 } 705 }
710 return (FX_DWORD)((FXJPEG_Context*)pContext)->m_SrcMgr.bytes_in_buffer; 706 return (FX_DWORD)((FXJPEG_Context*)pContext)->m_SrcMgr.bytes_in_buffer;
711 } 707 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698