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

Side by Side Diff: core/fpdfapi/page/fpdf_page_parser_old.cpp

Issue 2478253002: Revert of Remove CPDF_Object::Release() in favor of direct delete (Closed)
Patch Set: Created 4 years, 1 month 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/fpdfapi/page/cpdf_streamcontentparser.cpp ('k') | core/fpdfapi/parser/cfdf_document.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 "core/fpdfapi/page/pageint.h" 7 #include "core/fpdfapi/page/pageint.h"
8 8
9 #include <limits.h> 9 #include <limits.h>
10 10
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 const uint8_t* pData, 131 const uint8_t* pData,
132 uint32_t dwSize, 132 uint32_t dwSize,
133 const CFX_WeakPtr<CFX_ByteStringPool>& pPool) 133 const CFX_WeakPtr<CFX_ByteStringPool>& pPool)
134 : m_pBuf(pData), 134 : m_pBuf(pData),
135 m_Size(dwSize), 135 m_Size(dwSize),
136 m_Pos(0), 136 m_Pos(0),
137 m_pLastObj(nullptr), 137 m_pLastObj(nullptr),
138 m_pPool(pPool) {} 138 m_pPool(pPool) {}
139 139
140 CPDF_StreamParser::~CPDF_StreamParser() { 140 CPDF_StreamParser::~CPDF_StreamParser() {
141 delete m_pLastObj; 141 if (m_pLastObj) {
142 m_pLastObj->Release();
143 }
142 } 144 }
143 145
144 CPDF_Stream* CPDF_StreamParser::ReadInlineStream(CPDF_Document* pDoc, 146 CPDF_Stream* CPDF_StreamParser::ReadInlineStream(CPDF_Document* pDoc,
145 CPDF_Dictionary* pDict, 147 CPDF_Dictionary* pDict,
146 CPDF_Object* pCSObj) { 148 CPDF_Object* pCSObj) {
147 if (m_Pos == m_Size) 149 if (m_Pos == m_Size)
148 return nullptr; 150 return nullptr;
149 151
150 if (PDFCharIsWhitespace(m_pBuf[m_Pos])) 152 if (PDFCharIsWhitespace(m_pBuf[m_Pos]))
151 m_Pos++; 153 m_Pos++;
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 m_Pos = dwSavePos; 245 m_Pos = dwSavePos;
244 pData = FX_Alloc(uint8_t, dwStreamSize); 246 pData = FX_Alloc(uint8_t, dwStreamSize);
245 FXSYS_memcpy(pData, m_pBuf + m_Pos, dwStreamSize); 247 FXSYS_memcpy(pData, m_pBuf + m_Pos, dwStreamSize);
246 m_Pos += dwStreamSize; 248 m_Pos += dwStreamSize;
247 } 249 }
248 pDict->SetIntegerFor("Length", (int)dwStreamSize); 250 pDict->SetIntegerFor("Length", (int)dwStreamSize);
249 return new CPDF_Stream(pData, dwStreamSize, pDict); 251 return new CPDF_Stream(pData, dwStreamSize, pDict);
250 } 252 }
251 253
252 CPDF_StreamParser::SyntaxType CPDF_StreamParser::ParseNextElement() { 254 CPDF_StreamParser::SyntaxType CPDF_StreamParser::ParseNextElement() {
253 delete m_pLastObj; 255 if (m_pLastObj) {
254 m_pLastObj = nullptr; 256 m_pLastObj->Release();
257 m_pLastObj = nullptr;
258 }
255 259
256 m_WordSize = 0; 260 m_WordSize = 0;
257 bool bIsNumber = true; 261 bool bIsNumber = true;
258 if (!PositionIsInBounds()) 262 if (!PositionIsInBounds())
259 return EndOfData; 263 return EndOfData;
260 264
261 int ch = m_pBuf[m_Pos++]; 265 int ch = m_pBuf[m_Pos++];
262 while (1) { 266 while (1) {
263 while (PDFCharIsWhitespace(ch)) { 267 while (PDFCharIsWhitespace(ch)) {
264 if (!PositionIsInBounds()) 268 if (!PositionIsInBounds())
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 if (m_WordSize == 1) 367 if (m_WordSize == 1)
364 return new CPDF_String(ReadHexString(), true); 368 return new CPDF_String(ReadHexString(), true);
365 369
366 CPDF_Dictionary* pDict = new CPDF_Dictionary(m_pPool); 370 CPDF_Dictionary* pDict = new CPDF_Dictionary(m_pPool);
367 while (1) { 371 while (1) {
368 GetNextWord(bIsNumber); 372 GetNextWord(bIsNumber);
369 if (m_WordSize == 2 && m_WordBuffer[0] == '>') 373 if (m_WordSize == 2 && m_WordBuffer[0] == '>')
370 break; 374 break;
371 375
372 if (!m_WordSize || m_WordBuffer[0] != '/') { 376 if (!m_WordSize || m_WordBuffer[0] != '/') {
373 delete pDict; 377 pDict->Release();
374 return nullptr; 378 return nullptr;
375 } 379 }
376 380
377 CFX_ByteString key = 381 CFX_ByteString key =
378 PDF_NameDecode(CFX_ByteStringC(m_WordBuffer + 1, m_WordSize - 1)); 382 PDF_NameDecode(CFX_ByteStringC(m_WordBuffer + 1, m_WordSize - 1));
379 CPDF_Object* pObj = ReadNextObject(true, 0); 383 CPDF_Object* pObj = ReadNextObject(true, 0);
380 if (!pObj) { 384 if (!pObj) {
381 delete pDict; 385 pDict->Release();
382 return nullptr; 386 return nullptr;
383 } 387 }
384 388
385 if (key.IsEmpty()) 389 if (key.IsEmpty())
386 delete pObj; 390 pObj->Release();
387 else 391 else
388 pDict->SetFor(key, pObj); 392 pDict->SetFor(key, pObj);
389 } 393 }
390 return pDict; 394 return pDict;
391 } 395 }
392 396
393 if (first_char == '[') { 397 if (first_char == '[') {
394 if ((!bAllowNestedArray && dwInArrayLevel) || 398 if ((!bAllowNestedArray && dwInArrayLevel) ||
395 dwInArrayLevel > kMaxNestedArrayLevel) { 399 dwInArrayLevel > kMaxNestedArrayLevel) {
396 return nullptr; 400 return nullptr;
(...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after
833 } 837 }
834 m_Status = Done; 838 m_Status = Done;
835 return; 839 return;
836 } 840 }
837 steps++; 841 steps++;
838 if (pPause && pPause->NeedToPauseNow()) { 842 if (pPause && pPause->NeedToPauseNow()) {
839 break; 843 break;
840 } 844 }
841 } 845 }
842 } 846 }
OLDNEW
« no previous file with comments | « core/fpdfapi/page/cpdf_streamcontentparser.cpp ('k') | core/fpdfapi/parser/cfdf_document.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698