From d9d20a47e2c9af8630536786d614eaed229056a8 Mon Sep 17 00:00:00 2001 From: Nicolas Pena Date: Wed, 22 Mar 2017 18:28:45 -0400 Subject: Return errors after validation instead of ASSERT in CPDF_DataAvail MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I909deca1d0bfc6de5ac0fd2e6956f9b918caf17a Reviewed-on: https://pdfium-review.googlesource.com/3157 Reviewed-by: Lei Zhang Commit-Queue: Nicolás Peña --- core/fpdfapi/parser/cpdf_data_avail.cpp | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) (limited to 'core') diff --git a/core/fpdfapi/parser/cpdf_data_avail.cpp b/core/fpdfapi/parser/cpdf_data_avail.cpp index 127944037b..5a2db8861c 100644 --- a/core/fpdfapi/parser/cpdf_data_avail.cpp +++ b/core/fpdfapi/parser/cpdf_data_avail.cpp @@ -1413,9 +1413,8 @@ CPDF_DataAvail::DocAvailStatus CPDF_DataAvail::CheckLinearizedFirstPage( return DataNotAvailable; m_bAnnotsLoad = true; } - const bool is_page_valid = ValidatePage(dwPage); - (void)is_page_valid; - ASSERT(is_page_valid); + if (!ValidatePage(dwPage)) + return DataError; return DataAvailable; } @@ -1559,9 +1558,8 @@ CPDF_DataAvail::DocAvailStatus CPDF_DataAvail::IsPageAvail( ResetFirstCheck(dwPage); m_pagesLoadState.insert(dwPage); - const bool is_page_valid = ValidatePage(dwPage); - (void)is_page_valid; - ASSERT(is_page_valid); + if (!ValidatePage(dwPage)) + return DataError; return DataAvailable; } @@ -1625,7 +1623,8 @@ CPDF_Dictionary* CPDF_DataAvail::GetPage(int index) { m_pDocument->ReplaceIndirectObjectIfHigherGeneration( dwObjNum, ParseIndirectObjectAt(0, dwObjNum, m_pDocument)); } - ValidatePage(index); + if (!ValidatePage(index)) + return nullptr; return m_pDocument->GetPage(index); } @@ -1661,9 +1660,8 @@ CPDF_DataAvail::DocFormStatus CPDF_DataAvail::IsFormAvail( } m_objs_array.clear(); - const bool is_form_valid = ValidateForm(); - (void)is_form_valid; - ASSERT(is_form_valid); + if (!ValidateForm()) + return FormError; return FormAvailable; } -- cgit v1.2.3