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

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

Issue 1145843005: Revert "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 }
56 int ret = 0; 59 int ret = 0;
57 if(!file_ptr->ReadBlock(src_buf, 0, src_size)) { 60 if(!file_ptr->ReadBlock(src_buf, 0, src_size)) {
58 goto failed; 61 goto failed;
59 } 62 }
60 pContext = CJBig2_Context::CreateContext(&m_Module, NULL, 0, src_buf, src_si ze, JBIG2_FILE_STREAM, &m_SymbolDictCache); 63 pContext = CJBig2_Context::CreateContext(&m_Module, NULL, 0, src_buf, src_si ze, JBIG2_FILE_STREAM, &m_SymbolDictCache);
61 if(pContext == NULL) { 64 if(pContext == NULL) {
62 goto failed; 65 goto failed;
63 } 66 }
64 ret = pContext->getFirstPage(&dest_image, NULL); 67 ret = pContext->getFirstPage(&dest_image, NULL);
65 CJBig2_Context::DestroyContext(pContext); 68 CJBig2_Context::DestroyContext(pContext);
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 FX_DWORD& width, FX_DWORD& height, FX_DWORD& pitch, FX_LPBYTE& dest_buf, IFX_Pause* pPause) 126 FX_DWORD& width, FX_DWORD& height, FX_DWORD& pitch, FX_LPBYTE& dest_buf, IFX_Pause* pPause)
124 { 127 {
125 if(!pJbig2Context) { 128 if(!pJbig2Context) {
126 return FXCODEC_STATUS_ERR_PARAMS; 129 return FXCODEC_STATUS_ERR_PARAMS;
127 } 130 }
128 CCodec_Jbig2Context* m_pJbig2Context = (CCodec_Jbig2Context*)pJbig2Context; 131 CCodec_Jbig2Context* m_pJbig2Context = (CCodec_Jbig2Context*)pJbig2Context;
129 m_pJbig2Context->m_bFileReader = TRUE; 132 m_pJbig2Context->m_bFileReader = TRUE;
130 m_pJbig2Context->m_dest_image = NULL; 133 m_pJbig2Context->m_dest_image = NULL;
131 m_pJbig2Context->m_src_size = (FX_DWORD)file_ptr->GetSize(); 134 m_pJbig2Context->m_src_size = (FX_DWORD)file_ptr->GetSize();
132 m_pJbig2Context->m_src_buf = FX_Alloc(FX_BYTE, m_pJbig2Context->m_src_size); 135 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 }
133 int ret = 0; 139 int ret = 0;
134 if(!file_ptr->ReadBlock((void*)m_pJbig2Context->m_src_buf, 0, m_pJbig2Contex t->m_src_size)) { 140 if(!file_ptr->ReadBlock((void*)m_pJbig2Context->m_src_buf, 0, m_pJbig2Contex t->m_src_size)) {
135 goto failed; 141 goto failed;
136 } 142 }
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); 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);
138 if(m_pJbig2Context->m_pContext == NULL) { 144 if(m_pJbig2Context->m_pContext == NULL) {
139 goto failed; 145 goto failed;
140 } 146 }
141 ret = m_pJbig2Context->m_pContext->getFirstPage(&m_pJbig2Context->m_dest_ima ge, pPause); 147 ret = m_pJbig2Context->m_pContext->getFirstPage(&m_pJbig2Context->m_dest_ima ge, pPause);
142 if(m_pJbig2Context->m_pContext->GetProcessiveStatus() == FXCODEC_STATUS_DECO DE_TOBECONTINUE) { 148 if(m_pJbig2Context->m_pContext->GetProcessiveStatus() == FXCODEC_STATUS_DECO DE_TOBECONTINUE) {
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 dword_buf[i] = ~dword_buf[i]; 203 dword_buf[i] = ~dword_buf[i];
198 } 204 }
199 return FXCODEC_STATUS_DECODE_FINISH; 205 return FXCODEC_STATUS_DECODE_FINISH;
200 } 206 }
201 } 207 }
202 return m_pJbig2Context->m_pContext->GetProcessiveStatus(); 208 return m_pJbig2Context->m_pContext->GetProcessiveStatus();
203 } 209 }
204 210
205 211
206 212
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