| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 } |
| OLD | NEW |