From f47ab5401690e29be552279e6327408bacde0c63 Mon Sep 17 00:00:00 2001 From: Jun Fang Date: Mon, 4 Aug 2014 12:58:19 -0700 Subject: 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 --- core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp | 13 +++++-------- 1 file 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; } -- cgit v1.2.3