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

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

Issue 2520493002: Make CPDF_Stream() take unique_ptr's to its dictionary. (Closed)
Patch Set: rebase, lint, fix new test. 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_image.cpp ('k') | core/fpdfapi/parser/cpdf_object_unittest.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 2016 PDFium Authors. All rights reserved. 1 // Copyright 2016 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 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 break; 226 break;
227 } 227 }
228 dwStreamSize += m_Pos - dwPrevPos; 228 dwStreamSize += m_Pos - dwPrevPos;
229 } 229 }
230 m_Pos = dwSavePos; 230 m_Pos = dwSavePos;
231 pData = FX_Alloc(uint8_t, dwStreamSize); 231 pData = FX_Alloc(uint8_t, dwStreamSize);
232 FXSYS_memcpy(pData, m_pBuf + m_Pos, dwStreamSize); 232 FXSYS_memcpy(pData, m_pBuf + m_Pos, dwStreamSize);
233 m_Pos += dwStreamSize; 233 m_Pos += dwStreamSize;
234 } 234 }
235 pDict->SetNewFor<CPDF_Number>("Length", (int)dwStreamSize); 235 pDict->SetNewFor<CPDF_Number>("Length", (int)dwStreamSize);
236 return new CPDF_Stream(pData, dwStreamSize, pDict); 236 return new CPDF_Stream(pData, dwStreamSize, pdfium::WrapUnique(pDict));
237 } 237 }
238 238
239 CPDF_StreamParser::SyntaxType CPDF_StreamParser::ParseNextElement() { 239 CPDF_StreamParser::SyntaxType CPDF_StreamParser::ParseNextElement() {
240 delete m_pLastObj; 240 delete m_pLastObj;
241 m_pLastObj = nullptr; 241 m_pLastObj = nullptr;
242 242
243 m_WordSize = 0; 243 m_WordSize = 0;
244 bool bIsNumber = true; 244 bool bIsNumber = true;
245 if (!PositionIsInBounds()) 245 if (!PositionIsInBounds())
246 return EndOfData; 246 return EndOfData;
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after
616 616
617 if (buf.GetLength() > kMaxStringLength) 617 if (buf.GetLength() > kMaxStringLength)
618 return CFX_ByteString(buf.GetBuffer(), kMaxStringLength); 618 return CFX_ByteString(buf.GetBuffer(), kMaxStringLength);
619 619
620 return buf.MakeString(); 620 return buf.MakeString();
621 } 621 }
622 622
623 bool CPDF_StreamParser::PositionIsInBounds() const { 623 bool CPDF_StreamParser::PositionIsInBounds() const {
624 return m_Pos < m_Size; 624 return m_Pos < m_Size;
625 } 625 }
OLDNEW
« no previous file with comments | « core/fpdfapi/page/cpdf_image.cpp ('k') | core/fpdfapi/parser/cpdf_object_unittest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698