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

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

Issue 2484953003: Force compiler to deduce src type for checked_cast<dst, src>. (Closed)
Patch Set: 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 | « no previous file | core/fpdfdoc/cpdf_formfield.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/parser/cpdf_parser.h" 7 #include "core/fpdfapi/parser/cpdf_parser.h"
8 8
9 #include <vector> 9 #include <vector>
10 10
(...skipping 1001 matching lines...) Expand 10 before | Expand all | Expand 10 after
1012 acc.LoadAllData(pStream); 1012 acc.LoadAllData(pStream);
1013 1013
1014 const uint8_t* pData = acc.GetData(); 1014 const uint8_t* pData = acc.GetData();
1015 uint32_t dwTotalSize = acc.GetSize(); 1015 uint32_t dwTotalSize = acc.GetSize();
1016 uint32_t segindex = 0; 1016 uint32_t segindex = 0;
1017 for (uint32_t i = 0; i < arrIndex.size(); i++) { 1017 for (uint32_t i = 0; i < arrIndex.size(); i++) {
1018 int32_t startnum = arrIndex[i].first; 1018 int32_t startnum = arrIndex[i].first;
1019 if (startnum < 0) 1019 if (startnum < 0)
1020 continue; 1020 continue;
1021 1021
1022 m_dwXrefStartObjNum = 1022 m_dwXrefStartObjNum = pdfium::base::checked_cast<uint32_t>(startnum);
1023 pdfium::base::checked_cast<uint32_t, int32_t>(startnum); 1023 uint32_t count = pdfium::base::checked_cast<uint32_t>(arrIndex[i].second);
1024 uint32_t count =
1025 pdfium::base::checked_cast<uint32_t, int32_t>(arrIndex[i].second);
1026 FX_SAFE_UINT32 dwCaculatedSize = segindex; 1024 FX_SAFE_UINT32 dwCaculatedSize = segindex;
1027 dwCaculatedSize += count; 1025 dwCaculatedSize += count;
1028 dwCaculatedSize *= totalWidth; 1026 dwCaculatedSize *= totalWidth;
1029 if (!dwCaculatedSize.IsValid() || 1027 if (!dwCaculatedSize.IsValid() ||
1030 dwCaculatedSize.ValueOrDie() > dwTotalSize) { 1028 dwCaculatedSize.ValueOrDie() > dwTotalSize) {
1031 continue; 1029 continue;
1032 } 1030 }
1033 1031
1034 const uint8_t* segstart = pData + segindex * totalWidth; 1032 const uint8_t* segstart = pData + segindex * totalWidth;
1035 FX_SAFE_UINT32 dwMaxObjNum = startnum; 1033 FX_SAFE_UINT32 dwMaxObjNum = startnum;
(...skipping 548 matching lines...) Expand 10 before | Expand all | Expand 10 after
1584 if (!LoadLinearizedAllCrossRefV4(m_LastXRefOffset, m_dwXrefStartObjNum) && 1582 if (!LoadLinearizedAllCrossRefV4(m_LastXRefOffset, m_dwXrefStartObjNum) &&
1585 !LoadLinearizedAllCrossRefV5(m_LastXRefOffset)) { 1583 !LoadLinearizedAllCrossRefV5(m_LastXRefOffset)) {
1586 m_LastXRefOffset = 0; 1584 m_LastXRefOffset = 0;
1587 m_pSyntax->m_MetadataObjnum = dwSaveMetadataObjnum; 1585 m_pSyntax->m_MetadataObjnum = dwSaveMetadataObjnum;
1588 return FORMAT_ERROR; 1586 return FORMAT_ERROR;
1589 } 1587 }
1590 1588
1591 m_pSyntax->m_MetadataObjnum = dwSaveMetadataObjnum; 1589 m_pSyntax->m_MetadataObjnum = dwSaveMetadataObjnum;
1592 return SUCCESS; 1590 return SUCCESS;
1593 } 1591 }
OLDNEW
« no previous file with comments | « no previous file | core/fpdfdoc/cpdf_formfield.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698