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

Side by Side Diff: core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp

Issue 1585823003: Correct the way to count pages and to avoid infinite loop (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: address comments and rebase Created 4 years, 11 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 "core/include/fpdfapi/fpdf_parser.h" 7 #include "core/include/fpdfapi/fpdf_parser.h"
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <memory> 10 #include <memory>
(...skipping 18 matching lines...) Expand all
29 // A limit on the maximum object number in the xref table. Theoretical limits 29 // A limit on the maximum object number in the xref table. Theoretical limits
30 // are higher, but this may be large enough in practice. 30 // are higher, but this may be large enough in practice.
31 const FX_DWORD kMaxObjectNumber = 1048576; 31 const FX_DWORD kMaxObjectNumber = 1048576;
32 32
33 struct SearchTagRecord { 33 struct SearchTagRecord {
34 const char* m_pTag; 34 const char* m_pTag;
35 FX_DWORD m_Len; 35 FX_DWORD m_Len;
36 FX_DWORD m_Offset; 36 FX_DWORD m_Offset;
37 }; 37 };
38 38
39 template <typename T>
40 class ScopedSetInsertion {
41 public:
42 ScopedSetInsertion(std::set<T>* org_set, T elem)
43 : m_Set(org_set), m_Entry(elem) {
44 m_Set->insert(m_Entry);
45 }
46 ~ScopedSetInsertion() { m_Set->erase(m_Entry); }
47
48 private:
49 std::set<T>* const m_Set;
50 const T m_Entry;
51 };
52
53 int CompareFileSize(const void* p1, const void* p2) { 39 int CompareFileSize(const void* p1, const void* p2) {
54 return *(FX_FILESIZE*)p1 - *(FX_FILESIZE*)p2; 40 return *(FX_FILESIZE*)p1 - *(FX_FILESIZE*)p2;
55 } 41 }
56 42
57 int32_t GetHeaderOffset(IFX_FileRead* pFile) { 43 int32_t GetHeaderOffset(IFX_FileRead* pFile) {
58 const FX_DWORD tag = FXDWORD_FROM_LSBFIRST(0x46445025); 44 const FX_DWORD tag = FXDWORD_FROM_LSBFIRST(0x46445025);
59 const size_t kBufSize = 4; 45 const size_t kBufSize = 4;
60 uint8_t buf[kBufSize]; 46 uint8_t buf[kBufSize];
61 int32_t offset = 0; 47 int32_t offset = 0;
62 while (offset <= 1024) { 48 while (offset <= 1024) {
(...skipping 4945 matching lines...) Expand 10 before | Expand all | Expand 10 after
5008 if (!m_pLinearizedDict) 4994 if (!m_pLinearizedDict)
5009 return -1; 4995 return -1;
5010 CPDF_Array* pRange = m_pLinearizedDict->GetArray("H"); 4996 CPDF_Array* pRange = m_pLinearizedDict->GetArray("H");
5011 if (!pRange) 4997 if (!pRange)
5012 return -1; 4998 return -1;
5013 CPDF_Object* pStreamLen = pRange->GetElementValue(1); 4999 CPDF_Object* pStreamLen = pRange->GetElementValue(1);
5014 if (!pStreamLen) 5000 if (!pStreamLen)
5015 return -1; 5001 return -1;
5016 return pStreamLen->GetInteger(); 5002 return pStreamLen->GetInteger();
5017 } 5003 }
OLDNEW
« no previous file with comments | « core/src/fpdfapi/fpdf_parser/fpdf_parser_document.cpp ('k') | fpdfsdk/src/fpdfview_embeddertest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698