summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2014-09-18 12:11:56 -0700
committerJun Fang <jun_fang@foxitsoftware.com>2014-09-29 14:03:38 -0700
commit0f4a4e8d744ee16e8ea4514638034d0031b72ed4 (patch)
treea79764e6de4bea87b02ae49145b561b3aa58d6f8
parente3280978ae7ba9b0590a5dd4ae122d4ed5ef9170 (diff)
downloadpdfium-0f4a4e8d744ee16e8ea4514638034d0031b72ed4.tar.xz
Fix Regression: Incomplete file loading is seen for multi page pdf files.
This was introduced at PDFium revision 12a9940. There was a subtle logic change for null |parray|. BUG=415438 R=jun_fang@foxitsoftware.com Review URL: https://codereview.chromium.org/579363002
-rw-r--r--core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp19
1 files changed, 7 insertions, 12 deletions
diff --git a/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp b/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp
index a81229b259..3cc5af6685 100644
--- a/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp
+++ b/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp
@@ -1015,26 +1015,21 @@ FX_BOOL CPDF_Parser::LoadCrossRefV5(FX_FILESIZE pos, FX_FILESIZE& prev, FX_BOOL
} else {
m_Trailers.Add((CPDF_Dictionary*)pStream->GetDict()->Clone());
}
- FX_DWORD nSegs = 0;
- std::vector <std::pair <FX_INT32, FX_INT32>> arrIndex;
+ std::vector<std::pair<FX_INT32, FX_INT32> > arrIndex;
CPDF_Array* pArray = pStream->GetDict()->GetArray(FX_BSTRC("Index"));
if (pArray) {
FX_DWORD nPairSize = pArray->GetCount() / 2;
- CPDF_Object* pStartNumObj = NULL;
- CPDF_Object* pCountObj = NULL;
for (FX_DWORD i = 0; i < nPairSize; i++) {
- pStartNumObj = pArray->GetElement(i * 2);
- pCountObj = pArray->GetElement(i * 2 + 1);
+ CPDF_Object* pStartNumObj = pArray->GetElement(i * 2);
+ CPDF_Object* pCountObj = pArray->GetElement(i * 2 + 1);
if (pStartNumObj && pStartNumObj->GetType() == PDFOBJ_NUMBER
&& pCountObj && pCountObj->GetType() == PDFOBJ_NUMBER) {
arrIndex.push_back(std::make_pair(pStartNumObj->GetInteger(), pCountObj->GetInteger()));
}
}
- nSegs = arrIndex.size();
- if (nSegs == 0) {
- arrIndex.push_back(std::make_pair(0, size));
- nSegs = 1;
- }
+ }
+ if (arrIndex.size() == 0) {
+ arrIndex.push_back(std::make_pair(0, size));
}
pArray = pStream->GetDict()->GetArray(FX_BSTRC("W"));
if (pArray == NULL) {
@@ -1057,7 +1052,7 @@ FX_BOOL CPDF_Parser::LoadCrossRefV5(FX_FILESIZE pos, FX_FILESIZE& prev, FX_BOOL
FX_LPCBYTE pData = acc.GetData();
FX_DWORD dwTotalSize = acc.GetSize();
FX_DWORD segindex = 0;
- for (FX_DWORD i = 0; i < nSegs; i ++) {
+ for (FX_DWORD i = 0; i < arrIndex.size(); i ++) {
FX_INT32 startnum = arrIndex[i].first;
if (startnum < 0) {
continue;