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

Side by Side Diff: core/src/fpdfapi/fpdf_page/fpdf_page_parser_old.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
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/fpdfapi/fpdf_page.h" 7 #include "../../../include/fpdfapi/fpdf_page.h"
8 #include "../../../include/fpdfapi/fpdf_module.h" 8 #include "../../../include/fpdfapi/fpdf_module.h"
9 #include "../../../include/fxcodec/fx_codec.h" 9 #include "../../../include/fxcodec/fx_codec.h"
10 #include "pageint.h" 10 #include "pageint.h"
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 } 255 }
256 int ncomps = pDecoder->CountComps(); 256 int ncomps = pDecoder->CountComps();
257 int bpc = pDecoder->GetBPC(); 257 int bpc = pDecoder->GetBPC();
258 int width = pDecoder->GetWidth(); 258 int width = pDecoder->GetWidth();
259 int height = pDecoder->GetHeight(); 259 int height = pDecoder->GetHeight();
260 int pitch = (width * ncomps * bpc + 7) / 8; 260 int pitch = (width * ncomps * bpc + 7) / 8;
261 if (height == 0 || pitch > (1 << 30) / height) { 261 if (height == 0 || pitch > (1 << 30) / height) {
262 delete pDecoder; 262 delete pDecoder;
263 return -1; 263 return -1;
264 } 264 }
265 dest_buf = FX_Alloc2D(FX_BYTE, pitch, height); 265 dest_size = pitch * height;
266 dest_size = pitch * height; // Safe since checked alloc returned. 266 dest_buf = FX_Alloc( FX_BYTE, dest_size);
267 for (int row = 0; row < height; row ++) { 267 for (int row = 0; row < height; row ++) {
268 FX_LPBYTE pLine = pDecoder->GetScanline(row); 268 FX_LPBYTE pLine = pDecoder->GetScanline(row);
269 if (pLine == NULL) { 269 if (pLine == NULL) {
270 break; 270 break;
271 } 271 }
272 FXSYS_memcpy32(dest_buf + row * pitch, pLine, pitch); 272 FXSYS_memcpy32(dest_buf + row * pitch, pLine, pitch);
273 } 273 }
274 FX_DWORD srcoff = pDecoder->GetSrcOffset(); 274 FX_DWORD srcoff = pDecoder->GetSrcOffset();
275 delete pDecoder; 275 delete pDecoder;
276 return srcoff; 276 return srcoff;
(...skipping 766 matching lines...) Expand 10 before | Expand all | Expand 10 after
1043 FX_DWORD i; 1043 FX_DWORD i;
1044 for (i = 0; i < m_nStreams; i ++) { 1044 for (i = 0; i < m_nStreams; i ++) {
1045 FX_DWORD size = m_pStreamArray[i]->GetSize(); 1045 FX_DWORD size = m_pStreamArray[i]->GetSize();
1046 if (m_Size + size + 1 <= m_Size) { 1046 if (m_Size + size + 1 <= m_Size) {
1047 m_Status = Done; 1047 m_Status = Done;
1048 return; 1048 return;
1049 } 1049 }
1050 m_Size += size + 1; 1050 m_Size += size + 1;
1051 } 1051 }
1052 m_pData = FX_Alloc(FX_BYTE, m_Size); 1052 m_pData = FX_Alloc(FX_BYTE, m_Size);
1053 if (!m_pData) {
1054 m_Status = Done;
1055 return;
1056 }
1053 FX_DWORD pos = 0; 1057 FX_DWORD pos = 0;
1054 for (i = 0; i < m_nStreams; i ++) { 1058 for (i = 0; i < m_nStreams; i ++) {
1055 FXSYS_memcpy32(m_pData + pos, m_pStreamArray[i]->GetData (), m_pStreamArray[i]->GetSize()); 1059 FXSYS_memcpy32(m_pData + pos, m_pStreamArray[i]->GetData (), m_pStreamArray[i]->GetSize());
1056 pos += m_pStreamArray[i]->GetSize() + 1; 1060 pos += m_pStreamArray[i]->GetSize() + 1;
1057 m_pData[pos - 1] = ' '; 1061 m_pData[pos - 1] = ' ';
1058 delete m_pStreamArray[i]; 1062 delete m_pStreamArray[i];
1059 } 1063 }
1060 FX_Free(m_pStreamArray); 1064 FX_Free(m_pStreamArray);
1061 m_pStreamArray = NULL; 1065 m_pStreamArray = NULL;
1062 } else { 1066 } else {
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
1141 return 100; 1145 return 100;
1142 } 1146 }
1143 if (m_InternalStage == PAGEPARSE_STAGE_GETCONTENT) { 1147 if (m_InternalStage == PAGEPARSE_STAGE_GETCONTENT) {
1144 return 10; 1148 return 10;
1145 } 1149 }
1146 if (m_InternalStage == PAGEPARSE_STAGE_CHECKCLIP) { 1150 if (m_InternalStage == PAGEPARSE_STAGE_CHECKCLIP) {
1147 return 90; 1151 return 90;
1148 } 1152 }
1149 return 10 + 80 * m_CurrentOffset / m_Size; 1153 return 10 + 80 * m_CurrentOffset / m_Size;
1150 } 1154 }
OLDNEW
« no previous file with comments | « core/src/fpdfapi/fpdf_page/fpdf_page.cpp ('k') | core/src/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698