OLD | NEW |
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/fpdf_parser/include/cpdf_parser.h" | 7 #include "core/fpdfapi/fpdf_parser/include/cpdf_parser.h" |
8 | 8 |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 970 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
981 ShrinkObjectMap(size); | 981 ShrinkObjectMap(size); |
982 for (auto& it : m_ObjectInfo) | 982 for (auto& it : m_ObjectInfo) |
983 it.second.type = 0; | 983 it.second.type = 0; |
984 } else { | 984 } else { |
985 m_Trailers.Add(ToDictionary(pStream->GetDict()->Clone())); | 985 m_Trailers.Add(ToDictionary(pStream->GetDict()->Clone())); |
986 } | 986 } |
987 | 987 |
988 std::vector<std::pair<int32_t, int32_t>> arrIndex; | 988 std::vector<std::pair<int32_t, int32_t>> arrIndex; |
989 CPDF_Array* pArray = pStream->GetDict()->GetArrayBy("Index"); | 989 CPDF_Array* pArray = pStream->GetDict()->GetArrayBy("Index"); |
990 if (pArray) { | 990 if (pArray) { |
991 uint32_t nPairSize = pArray->GetCount() / 2; | 991 for (size_t i = 0; i < pArray->GetCount() / 2; i++) { |
992 for (uint32_t i = 0; i < nPairSize; i++) { | |
993 CPDF_Object* pStartNumObj = pArray->GetObjectAt(i * 2); | 992 CPDF_Object* pStartNumObj = pArray->GetObjectAt(i * 2); |
994 CPDF_Object* pCountObj = pArray->GetObjectAt(i * 2 + 1); | 993 CPDF_Object* pCountObj = pArray->GetObjectAt(i * 2 + 1); |
995 | 994 |
996 if (ToNumber(pStartNumObj) && ToNumber(pCountObj)) { | 995 if (ToNumber(pStartNumObj) && ToNumber(pCountObj)) { |
997 int nStartNum = pStartNumObj->GetInteger(); | 996 int nStartNum = pStartNumObj->GetInteger(); |
998 int nCount = pCountObj->GetInteger(); | 997 int nCount = pCountObj->GetInteger(); |
999 if (nStartNum >= 0 && nCount > 0) | 998 if (nStartNum >= 0 && nCount > 0) |
1000 arrIndex.push_back(std::make_pair(nStartNum, nCount)); | 999 arrIndex.push_back(std::make_pair(nStartNum, nCount)); |
1001 } | 1000 } |
1002 } | 1001 } |
1003 } | 1002 } |
1004 | 1003 |
1005 if (arrIndex.size() == 0) | 1004 if (arrIndex.size() == 0) |
1006 arrIndex.push_back(std::make_pair(0, size)); | 1005 arrIndex.push_back(std::make_pair(0, size)); |
1007 | 1006 |
1008 pArray = pStream->GetDict()->GetArrayBy("W"); | 1007 pArray = pStream->GetDict()->GetArrayBy("W"); |
1009 if (!pArray) { | 1008 if (!pArray) { |
1010 pStream->Release(); | 1009 pStream->Release(); |
1011 return FALSE; | 1010 return FALSE; |
1012 } | 1011 } |
1013 | 1012 |
1014 CFX_ArrayTemplate<uint32_t> WidthArray; | 1013 CFX_ArrayTemplate<uint32_t> WidthArray; |
1015 FX_SAFE_UINT32 dwAccWidth = 0; | 1014 FX_SAFE_UINT32 dwAccWidth = 0; |
1016 for (uint32_t i = 0; i < pArray->GetCount(); i++) { | 1015 for (size_t i = 0; i < pArray->GetCount(); i++) { |
1017 WidthArray.Add(pArray->GetIntegerAt(i)); | 1016 WidthArray.Add(pArray->GetIntegerAt(i)); |
1018 dwAccWidth += WidthArray[i]; | 1017 dwAccWidth += WidthArray[i]; |
1019 } | 1018 } |
1020 | 1019 |
1021 if (!dwAccWidth.IsValid() || WidthArray.GetSize() < 3) { | 1020 if (!dwAccWidth.IsValid() || WidthArray.GetSize() < 3) { |
1022 pStream->Release(); | 1021 pStream->Release(); |
1023 return FALSE; | 1022 return FALSE; |
1024 } | 1023 } |
1025 | 1024 |
1026 uint32_t totalWidth = dwAccWidth.ValueOrDie(); | 1025 uint32_t totalWidth = dwAccWidth.ValueOrDie(); |
(...skipping 617 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1644 if (!LoadLinearizedAllCrossRefV4(m_LastXRefOffset, m_dwXrefStartObjNum) && | 1643 if (!LoadLinearizedAllCrossRefV4(m_LastXRefOffset, m_dwXrefStartObjNum) && |
1645 !LoadLinearizedAllCrossRefV5(m_LastXRefOffset)) { | 1644 !LoadLinearizedAllCrossRefV5(m_LastXRefOffset)) { |
1646 m_LastXRefOffset = 0; | 1645 m_LastXRefOffset = 0; |
1647 m_pSyntax->m_MetadataObjnum = dwSaveMetadataObjnum; | 1646 m_pSyntax->m_MetadataObjnum = dwSaveMetadataObjnum; |
1648 return FORMAT_ERROR; | 1647 return FORMAT_ERROR; |
1649 } | 1648 } |
1650 | 1649 |
1651 m_pSyntax->m_MetadataObjnum = dwSaveMetadataObjnum; | 1650 m_pSyntax->m_MetadataObjnum = dwSaveMetadataObjnum; |
1652 return SUCCESS; | 1651 return SUCCESS; |
1653 } | 1652 } |
OLD | NEW |