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

Side by Side Diff: core/fpdfapi/fpdf_parser/cpdf_parser.cpp

Issue 1861403002: Rename FX_SAFE_DWORD to FX_SAFE_UINT32 (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 4 years, 8 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 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 994 matching lines...) Expand 10 before | Expand all | Expand 10 after
1005 if (arrIndex.size() == 0) 1005 if (arrIndex.size() == 0)
1006 arrIndex.push_back(std::make_pair(0, size)); 1006 arrIndex.push_back(std::make_pair(0, size));
1007 1007
1008 pArray = pStream->GetDict()->GetArrayBy("W"); 1008 pArray = pStream->GetDict()->GetArrayBy("W");
1009 if (!pArray) { 1009 if (!pArray) {
1010 pStream->Release(); 1010 pStream->Release();
1011 return FALSE; 1011 return FALSE;
1012 } 1012 }
1013 1013
1014 CFX_ArrayTemplate<uint32_t> WidthArray; 1014 CFX_ArrayTemplate<uint32_t> WidthArray;
1015 FX_SAFE_DWORD dwAccWidth = 0; 1015 FX_SAFE_UINT32 dwAccWidth = 0;
1016 for (uint32_t i = 0; i < pArray->GetCount(); i++) { 1016 for (uint32_t i = 0; i < pArray->GetCount(); i++) {
1017 WidthArray.Add(pArray->GetIntegerAt(i)); 1017 WidthArray.Add(pArray->GetIntegerAt(i));
1018 dwAccWidth += WidthArray[i]; 1018 dwAccWidth += WidthArray[i];
1019 } 1019 }
1020 1020
1021 if (!dwAccWidth.IsValid() || WidthArray.GetSize() < 3) { 1021 if (!dwAccWidth.IsValid() || WidthArray.GetSize() < 3) {
1022 pStream->Release(); 1022 pStream->Release();
1023 return FALSE; 1023 return FALSE;
1024 } 1024 }
1025 1025
1026 uint32_t totalWidth = dwAccWidth.ValueOrDie(); 1026 uint32_t totalWidth = dwAccWidth.ValueOrDie();
1027 CPDF_StreamAcc acc; 1027 CPDF_StreamAcc acc;
1028 acc.LoadAllData(pStream); 1028 acc.LoadAllData(pStream);
1029 1029
1030 const uint8_t* pData = acc.GetData(); 1030 const uint8_t* pData = acc.GetData();
1031 uint32_t dwTotalSize = acc.GetSize(); 1031 uint32_t dwTotalSize = acc.GetSize();
1032 uint32_t segindex = 0; 1032 uint32_t segindex = 0;
1033 for (uint32_t i = 0; i < arrIndex.size(); i++) { 1033 for (uint32_t i = 0; i < arrIndex.size(); i++) {
1034 int32_t startnum = arrIndex[i].first; 1034 int32_t startnum = arrIndex[i].first;
1035 if (startnum < 0) 1035 if (startnum < 0)
1036 continue; 1036 continue;
1037 1037
1038 m_dwXrefStartObjNum = 1038 m_dwXrefStartObjNum =
1039 pdfium::base::checked_cast<uint32_t, int32_t>(startnum); 1039 pdfium::base::checked_cast<uint32_t, int32_t>(startnum);
1040 uint32_t count = 1040 uint32_t count =
1041 pdfium::base::checked_cast<uint32_t, int32_t>(arrIndex[i].second); 1041 pdfium::base::checked_cast<uint32_t, int32_t>(arrIndex[i].second);
1042 FX_SAFE_DWORD dwCaculatedSize = segindex; 1042 FX_SAFE_UINT32 dwCaculatedSize = segindex;
1043 dwCaculatedSize += count; 1043 dwCaculatedSize += count;
1044 dwCaculatedSize *= totalWidth; 1044 dwCaculatedSize *= totalWidth;
1045 if (!dwCaculatedSize.IsValid() || 1045 if (!dwCaculatedSize.IsValid() ||
1046 dwCaculatedSize.ValueOrDie() > dwTotalSize) { 1046 dwCaculatedSize.ValueOrDie() > dwTotalSize) {
1047 continue; 1047 continue;
1048 } 1048 }
1049 1049
1050 const uint8_t* segstart = pData + segindex * totalWidth; 1050 const uint8_t* segstart = pData + segindex * totalWidth;
1051 FX_SAFE_DWORD dwMaxObjNum = startnum; 1051 FX_SAFE_UINT32 dwMaxObjNum = startnum;
1052 dwMaxObjNum += count; 1052 dwMaxObjNum += count;
1053 uint32_t dwV5Size = m_ObjectInfo.empty() ? 0 : GetLastObjNum() + 1; 1053 uint32_t dwV5Size = m_ObjectInfo.empty() ? 0 : GetLastObjNum() + 1;
1054 if (!dwMaxObjNum.IsValid() || dwMaxObjNum.ValueOrDie() > dwV5Size) 1054 if (!dwMaxObjNum.IsValid() || dwMaxObjNum.ValueOrDie() > dwV5Size)
1055 continue; 1055 continue;
1056 1056
1057 for (uint32_t j = 0; j < count; j++) { 1057 for (uint32_t j = 0; j < count; j++) {
1058 int32_t type = 1; 1058 int32_t type = 1;
1059 const uint8_t* entrystart = segstart + j * totalWidth; 1059 const uint8_t* entrystart = segstart + j * totalWidth;
1060 if (WidthArray[0]) 1060 if (WidthArray[0])
1061 type = GetVarInt(entrystart, WidthArray[0]); 1061 type = GetVarInt(entrystart, WidthArray[0]);
(...skipping 582 matching lines...) Expand 10 before | Expand all | Expand 10 after
1644 if (!LoadLinearizedAllCrossRefV4(m_LastXRefOffset, m_dwXrefStartObjNum) && 1644 if (!LoadLinearizedAllCrossRefV4(m_LastXRefOffset, m_dwXrefStartObjNum) &&
1645 !LoadLinearizedAllCrossRefV5(m_LastXRefOffset)) { 1645 !LoadLinearizedAllCrossRefV5(m_LastXRefOffset)) {
1646 m_LastXRefOffset = 0; 1646 m_LastXRefOffset = 0;
1647 m_pSyntax->m_MetadataObjnum = dwSaveMetadataObjnum; 1647 m_pSyntax->m_MetadataObjnum = dwSaveMetadataObjnum;
1648 return FORMAT_ERROR; 1648 return FORMAT_ERROR;
1649 } 1649 }
1650 1650
1651 m_pSyntax->m_MetadataObjnum = dwSaveMetadataObjnum; 1651 m_pSyntax->m_MetadataObjnum = dwSaveMetadataObjnum;
1652 return SUCCESS; 1652 return SUCCESS;
1653 } 1653 }
OLDNEW
« no previous file with comments | « core/fpdfapi/fpdf_parser/cpdf_hint_tables.cpp ('k') | core/fpdfapi/fpdf_render/fpdf_render_image.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698