summaryrefslogtreecommitdiff
path: root/core/src/fpdfapi/fpdf_parser
diff options
context:
space:
mode:
authorJun Fang <jun_fang@foxitsoftware.com>2014-08-04 12:58:19 -0700
committerJun Fang <jun_fang@foxitsoftware.com>2014-08-04 12:58:19 -0700
commitf47ab5401690e29be552279e6327408bacde0c63 (patch)
treedf151dd5ecfd8bba4ccb1884e2fa299f2cf5ed40 /core/src/fpdfapi/fpdf_parser
parent465c2a84ba709d932040c9e80db508e93c138da6 (diff)
downloadpdfium-f47ab5401690e29be552279e6327408bacde0c63.tar.xz
Fix a segmentation fault in CPDF_DataAvail::CheckPage due to invalid usage of i++
BUG=387979 R=tsepez@chromium.org Review URL: https://codereview.chromium.org/439733002
Diffstat (limited to 'core/src/fpdfapi/fpdf_parser')
-rw-r--r--core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp13
1 files changed, 5 insertions, 8 deletions
diff --git a/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp b/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp
index b90c784f6f..af3fcc7094 100644
--- a/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp
+++ b/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp
@@ -3234,10 +3234,9 @@ void CPDF_DataAvail::ResetFirstCheck(int iPage)
}
FX_BOOL CPDF_DataAvail::CheckPage(IFX_DownloadHints* pHints)
{
- FX_DWORD i = 0;
- FX_DWORD iLen = m_PageObjList.GetSize();
+ FX_DWORD iPageObjs = m_PageObjList.GetSize();
CFX_DWordArray UnavailObjList;
- for (; i < iLen; ++i) {
+ for (FX_DWORD i = 0; i < iPageObjs; ++i) {
FX_DWORD dwPageObjNum = m_PageObjList.GetAt(i);
FX_BOOL bExist = FALSE;
CPDF_Object *pObj = GetObject(dwPageObjNum, pHints, &bExist);
@@ -3276,16 +3275,15 @@ FX_BOOL CPDF_DataAvail::CheckPage(IFX_DownloadHints* pHints)
m_PageObjList.Append(UnavailObjList);
return FALSE;
}
- i = 0;
- iLen = m_PagesArray.GetSize();
- for (; i < iLen; ++i) {
+ FX_DWORD iPages = m_PagesArray.GetSize();
+ for (FX_DWORD i = 0; i < iPages; i++) {
CPDF_Object *pPages = (CPDF_Object *)m_PagesArray.GetAt(i);
if (!pPages) {
continue;
}
if (!GetPageKids(m_pCurrentParser, pPages)) {
pPages->Release();
- while (i++ < iLen) {
+ while (++i < iPages) {
pPages = (CPDF_Object *)m_PagesArray.GetAt(i);
pPages->Release();
}
@@ -3298,7 +3296,6 @@ FX_BOOL CPDF_DataAvail::CheckPage(IFX_DownloadHints* pHints)
m_PagesArray.RemoveAll();
if (!m_PageObjList.GetSize()) {
m_docStatus = PDF_DATAAVAIL_DONE;
- return TRUE;
}
return TRUE;
}