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

Side by Side Diff: core/src/fxcodec/codec/fx_codec_jbig.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_icc.cpp ('k') | core/src/fxcodec/codec/fx_codec_jpx_opj.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 CCodec_Jbig2Context::CCodec_Jbig2Context() 9 CCodec_Jbig2Context::CCodec_Jbig2Context()
10 { 10 {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 } 46 }
47 return TRUE; 47 return TRUE;
48 } 48 }
49 FX_BOOL CCodec_Jbig2Module::Decode(IFX_FileRead* file_ptr, 49 FX_BOOL CCodec_Jbig2Module::Decode(IFX_FileRead* file_ptr,
50 FX_DWORD& width, FX_DWORD& height, FX_DWORD& pitch, FX_LPBYTE& dest_buf) 50 FX_DWORD& width, FX_DWORD& height, FX_DWORD& pitch, FX_LPBYTE& dest_buf)
51 { 51 {
52 CJBig2_Context* pContext = NULL; 52 CJBig2_Context* pContext = NULL;
53 CJBig2_Image* dest_image = NULL; 53 CJBig2_Image* dest_image = NULL;
54 FX_DWORD src_size = (FX_DWORD)file_ptr->GetSize(); 54 FX_DWORD src_size = (FX_DWORD)file_ptr->GetSize();
55 FX_LPBYTE src_buf = FX_Alloc(FX_BYTE, src_size); 55 FX_LPBYTE src_buf = FX_Alloc(FX_BYTE, src_size);
56 if (src_buf == NULL) {
57 return FALSE;
58 }
59 int ret = 0; 56 int ret = 0;
60 if(!file_ptr->ReadBlock(src_buf, 0, src_size)) { 57 if(!file_ptr->ReadBlock(src_buf, 0, src_size)) {
61 goto failed; 58 goto failed;
62 } 59 }
63 pContext = CJBig2_Context::CreateContext(&m_Module, NULL, 0, src_buf, src_si ze, JBIG2_FILE_STREAM, &m_SymbolDictCache); 60 pContext = CJBig2_Context::CreateContext(&m_Module, NULL, 0, src_buf, src_si ze, JBIG2_FILE_STREAM, &m_SymbolDictCache);
64 if(pContext == NULL) { 61 if(pContext == NULL) {
65 goto failed; 62 goto failed;
66 } 63 }
67 ret = pContext->getFirstPage(&dest_image, NULL); 64 ret = pContext->getFirstPage(&dest_image, NULL);
68 CJBig2_Context::DestroyContext(pContext); 65 CJBig2_Context::DestroyContext(pContext);
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 FX_DWORD& width, FX_DWORD& height, FX_DWORD& pitch, FX_LPBYTE& dest_buf, IFX_Pause* pPause) 123 FX_DWORD& width, FX_DWORD& height, FX_DWORD& pitch, FX_LPBYTE& dest_buf, IFX_Pause* pPause)
127 { 124 {
128 if(!pJbig2Context) { 125 if(!pJbig2Context) {
129 return FXCODEC_STATUS_ERR_PARAMS; 126 return FXCODEC_STATUS_ERR_PARAMS;
130 } 127 }
131 CCodec_Jbig2Context* m_pJbig2Context = (CCodec_Jbig2Context*)pJbig2Context; 128 CCodec_Jbig2Context* m_pJbig2Context = (CCodec_Jbig2Context*)pJbig2Context;
132 m_pJbig2Context->m_bFileReader = TRUE; 129 m_pJbig2Context->m_bFileReader = TRUE;
133 m_pJbig2Context->m_dest_image = NULL; 130 m_pJbig2Context->m_dest_image = NULL;
134 m_pJbig2Context->m_src_size = (FX_DWORD)file_ptr->GetSize(); 131 m_pJbig2Context->m_src_size = (FX_DWORD)file_ptr->GetSize();
135 m_pJbig2Context->m_src_buf = FX_Alloc(FX_BYTE, m_pJbig2Context->m_src_size); 132 m_pJbig2Context->m_src_buf = FX_Alloc(FX_BYTE, m_pJbig2Context->m_src_size);
136 if (m_pJbig2Context->m_src_buf == NULL) {
137 return FXCODEC_STATUS_ERR_MEMORY;
138 }
139 int ret = 0; 133 int ret = 0;
140 if(!file_ptr->ReadBlock((void*)m_pJbig2Context->m_src_buf, 0, m_pJbig2Contex t->m_src_size)) { 134 if(!file_ptr->ReadBlock((void*)m_pJbig2Context->m_src_buf, 0, m_pJbig2Contex t->m_src_size)) {
141 goto failed; 135 goto failed;
142 } 136 }
143 m_pJbig2Context->m_pContext = CJBig2_Context::CreateContext(&m_Module, NULL, 0, m_pJbig2Context->m_src_buf, m_pJbig2Context->m_src_size, JBIG2_FILE_STREAM, &m_SymbolDictCache, pPause); 137 m_pJbig2Context->m_pContext = CJBig2_Context::CreateContext(&m_Module, NULL, 0, m_pJbig2Context->m_src_buf, m_pJbig2Context->m_src_size, JBIG2_FILE_STREAM, &m_SymbolDictCache, pPause);
144 if(m_pJbig2Context->m_pContext == NULL) { 138 if(m_pJbig2Context->m_pContext == NULL) {
145 goto failed; 139 goto failed;
146 } 140 }
147 ret = m_pJbig2Context->m_pContext->getFirstPage(&m_pJbig2Context->m_dest_ima ge, pPause); 141 ret = m_pJbig2Context->m_pContext->getFirstPage(&m_pJbig2Context->m_dest_ima ge, pPause);
148 if(m_pJbig2Context->m_pContext->GetProcessiveStatus() == FXCODEC_STATUS_DECO DE_TOBECONTINUE) { 142 if(m_pJbig2Context->m_pContext->GetProcessiveStatus() == FXCODEC_STATUS_DECO DE_TOBECONTINUE) {
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 dword_buf[i] = ~dword_buf[i]; 197 dword_buf[i] = ~dword_buf[i];
204 } 198 }
205 return FXCODEC_STATUS_DECODE_FINISH; 199 return FXCODEC_STATUS_DECODE_FINISH;
206 } 200 }
207 } 201 }
208 return m_pJbig2Context->m_pContext->GetProcessiveStatus(); 202 return m_pJbig2Context->m_pContext->GetProcessiveStatus();
209 } 203 }
210 204
211 205
212 206
OLDNEW
« no previous file with comments | « core/src/fxcodec/codec/fx_codec_icc.cpp ('k') | core/src/fxcodec/codec/fx_codec_jpx_opj.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698