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

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

Issue 1135893008: Re-land: Remove FX_Alloc() null checks now that it can't return NULL. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 5 years, 7 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/extension.h » ('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 <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 9
10 #include "../../../include/fxcodec/fx_codec.h" 10 #include "../../../include/fxcodec/fx_codec.h"
(...skipping 697 matching lines...) Expand 10 before | Expand all | Expand 10 after
708 FX_LPBYTE pChannel, pScanline, pPixel; 708 FX_LPBYTE pChannel, pScanline, pPixel;
709 709
710 if(image->comps[0].w != image->x1 || image->comps[0].h != image->y1) { 710 if(image->comps[0].w != image->x1 || image->comps[0].h != image->y1) {
711 return FALSE; 711 return FALSE;
712 } 712 }
713 if(pitch < (int)(image->comps[0].w * 8 * image->numcomps + 31) >> 5 << 2) { 713 if(pitch < (int)(image->comps[0].w * 8 * image->numcomps + 31) >> 5 << 2) {
714 return FALSE; 714 return FALSE;
715 } 715 }
716 FXSYS_memset8(dest_buf, 0xff, image->y1 * pitch); 716 FXSYS_memset8(dest_buf, 0xff, image->y1 * pitch);
717 FX_BYTE** channel_bufs = FX_Alloc(FX_BYTE*, image->numcomps); 717 FX_BYTE** channel_bufs = FX_Alloc(FX_BYTE*, image->numcomps);
718 if (channel_bufs == NULL) {
719 return FALSE;
720 }
721 FX_BOOL result = FALSE; 718 FX_BOOL result = FALSE;
722 int* adjust_comps = FX_Alloc(int, image->numcomps); 719 int* adjust_comps = FX_Alloc(int, image->numcomps);
723 if (adjust_comps == NULL) {
724 goto done;
725 }
726 for (i = 0; i < (int)image->numcomps; i ++) { 720 for (i = 0; i < (int)image->numcomps; i ++) {
727 channel_bufs[i] = dest_buf + offsets[i]; 721 channel_bufs[i] = dest_buf + offsets[i];
728 adjust_comps[i] = image->comps[i].prec - 8; 722 adjust_comps[i] = image->comps[i].prec - 8;
729 if(i > 0) { 723 if(i > 0) {
730 if(image->comps[i].dx != image->comps[i - 1].dx 724 if(image->comps[i].dx != image->comps[i - 1].dx
731 || image->comps[i].dy != image->comps[i - 1].dy 725 || image->comps[i].dy != image->comps[i - 1].dy
732 || image->comps[i].prec != image->comps[i - 1].prec) { 726 || image->comps[i].prec != image->comps[i - 1].prec) {
733 goto done; 727 goto done;
734 } 728 }
735 } 729 }
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
809 FX_BOOL CCodec_JpxModule::Decode(void* ctx, FX_LPBYTE dest_data, int pitch, FX_B OOL bTranslateColor, FX_LPBYTE offsets) 803 FX_BOOL CCodec_JpxModule::Decode(void* ctx, FX_LPBYTE dest_data, int pitch, FX_B OOL bTranslateColor, FX_LPBYTE offsets)
810 { 804 {
811 CJPX_Decoder* pDecoder = (CJPX_Decoder*)ctx; 805 CJPX_Decoder* pDecoder = (CJPX_Decoder*)ctx;
812 return pDecoder->Decode(dest_data, pitch, bTranslateColor, offsets); 806 return pDecoder->Decode(dest_data, pitch, bTranslateColor, offsets);
813 } 807 }
814 void CCodec_JpxModule::DestroyDecoder(void* ctx) 808 void CCodec_JpxModule::DestroyDecoder(void* ctx)
815 { 809 {
816 CJPX_Decoder* pDecoder = (CJPX_Decoder*)ctx; 810 CJPX_Decoder* pDecoder = (CJPX_Decoder*)ctx;
817 delete pDecoder; 811 delete pDecoder;
818 } 812 }
OLDNEW
« no previous file with comments | « core/src/fxcodec/codec/fx_codec_jbig.cpp ('k') | core/src/fxcrt/extension.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698