summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorxlou <xlou@chromium.org>2018-01-29 20:23:27 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-01-29 20:23:27 +0000
commit32d5de5948ff8a54b24d79e1f032857874b6053f (patch)
treebd8668b9784585bc6d320bf51ff2f7a28da938c2
parent75acda66db9db257ec92172ea1a30b6616117b8d (diff)
downloadpdfium-32d5de5948ff8a54b24d79e1f032857874b6053f.tar.xz
Change pageNums from uint16_t to uint32_t
Users of FPDF_ImportPages API may import more than 65535 pages. Hence changing pageNums definition to uint32_t. Change-Id: I5a79e9cdd3022141b4d35995e833390db1bf3696 Reviewed-on: https://pdfium-review.googlesource.com/24071 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Shirleen Lou <xlou@chromium.org>
-rw-r--r--fpdfsdk/fpdfppo.cpp26
1 files changed, 13 insertions, 13 deletions
diff --git a/fpdfsdk/fpdfppo.cpp b/fpdfsdk/fpdfppo.cpp
index 836d5723ca..d935ee9403 100644
--- a/fpdfsdk/fpdfppo.cpp
+++ b/fpdfsdk/fpdfppo.cpp
@@ -70,8 +70,8 @@ bool CopyInheritable(CPDF_Dictionary* pCurPageDict,
}
bool ParserPageRangeString(ByteString rangstring,
- int nCount,
- std::vector<uint16_t>* pageArray) {
+ uint32_t nCount,
+ std::vector<uint32_t>* pageArray) {
if (rangstring.IsEmpty())
return true;
@@ -93,13 +93,13 @@ bool ParserPageRangeString(ByteString rangstring,
cbMidRange = rangstring.Mid(nStringFrom, nStringTo.value() - nStringFrom);
auto nMid = cbMidRange.Find('-');
if (!nMid.has_value()) {
- uint16_t pageNum =
- pdfium::base::checked_cast<uint16_t>(atoi(cbMidRange.c_str()));
+ uint32_t pageNum =
+ pdfium::base::checked_cast<uint32_t>(atoi(cbMidRange.c_str()));
if (pageNum <= 0 || pageNum > nCount)
return false;
pageArray->push_back(pageNum);
} else {
- uint16_t nStartPageNum = pdfium::base::checked_cast<uint16_t>(
+ uint32_t nStartPageNum = pdfium::base::checked_cast<uint32_t>(
atoi(cbMidRange.Left(nMid.value()).c_str()));
if (nStartPageNum == 0)
return false;
@@ -109,13 +109,13 @@ bool ParserPageRangeString(ByteString rangstring,
if (nEnd == 0)
return false;
- uint16_t nEndPageNum = pdfium::base::checked_cast<uint16_t>(
+ uint32_t nEndPageNum = pdfium::base::checked_cast<uint32_t>(
atoi(cbMidRange.Mid(nMid.value(), nEnd).c_str()));
if (nStartPageNum < 0 || nStartPageNum > nEndPageNum ||
nEndPageNum > nCount) {
return false;
}
- for (uint16_t i = nStartPageNum; i <= nEndPageNum; ++i) {
+ for (uint32_t i = nStartPageNum; i <= nEndPageNum; ++i) {
pageArray->push_back(i);
}
}
@@ -126,13 +126,13 @@ bool ParserPageRangeString(ByteString rangstring,
bool GetPageNumbers(ByteString pageRange,
CPDF_Document* pSrcDoc,
- std::vector<uint16_t>* pageArray) {
- uint16_t nCount = pSrcDoc->GetPageCount();
+ std::vector<uint32_t>* pageArray) {
+ uint32_t nCount = pSrcDoc->GetPageCount();
if (!pageRange.IsEmpty()) {
if (!ParserPageRangeString(pageRange, nCount, pageArray))
return false;
} else {
- for (uint16_t i = 1; i <= nCount; ++i) {
+ for (uint32_t i = 1; i <= nCount; ++i) {
pageArray->push_back(i);
}
}
@@ -147,7 +147,7 @@ class CPDF_PageOrganizer {
~CPDF_PageOrganizer();
bool PDFDocInit();
- bool ExportPage(const std::vector<uint16_t>& pageNums, int nIndex);
+ bool ExportPage(const std::vector<uint32_t>& pageNums, int nIndex);
private:
using ObjectNumberMap = std::map<uint32_t, uint32_t>;
@@ -206,7 +206,7 @@ bool CPDF_PageOrganizer::PDFDocInit() {
return true;
}
-bool CPDF_PageOrganizer::ExportPage(const std::vector<uint16_t>& pageNums,
+bool CPDF_PageOrganizer::ExportPage(const std::vector<uint32_t>& pageNums,
int nIndex) {
int curpage = nIndex;
auto pObjNumberMap = pdfium::MakeUnique<ObjectNumberMap>();
@@ -372,7 +372,7 @@ FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDF_ImportPages(FPDF_DOCUMENT dest_doc,
if (!pSrcDoc)
return false;
- std::vector<uint16_t> pageArray;
+ std::vector<uint32_t> pageArray;
if (!GetPageNumbers(pagerange, pSrcDoc, &pageArray))
return false;