Remove unnecessary CheckedNumeric usage in CPDF_DataAvail.

In several places inside CPDF_DataAvail, the code needs to make sure the
uint32_t page number parameter can be safely converted into a signed
int. Combining CheckedNumeric and checked_cast() to do this does not
make sense, because checked_cast() already crashes on failure, so
CheckedNumeric would never have the opportunity to do anything
interesting. Just replace the CheckedNumeric variables with ints to
simplify the code.

Change-Id: If9af2f94cb9bda7f68e5fd049ac63305302f7b4b
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/67391
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
diff --git a/core/fpdfapi/parser/cpdf_data_avail.cpp b/core/fpdfapi/parser/cpdf_data_avail.cpp
index 457ae61..38b363d 100644
--- a/core/fpdfapi/parser/cpdf_data_avail.cpp
+++ b/core/fpdfapi/parser/cpdf_data_avail.cpp
@@ -676,8 +676,7 @@
 }
 
 bool CPDF_DataAvail::LoadDocPage(uint32_t dwPage) {
-  FX_SAFE_INT32 safePage = pdfium::base::checked_cast<int32_t>(dwPage);
-  int32_t iPage = safePage.ValueOrDie();
+  int iPage = pdfium::base::checked_cast<int>(dwPage);
   if (m_pDocument->GetPageCount() <= iPage ||
       m_pDocument->IsPageLoaded(iPage)) {
     m_docStatus = PDF_DATAAVAIL_DONE;
@@ -788,11 +787,8 @@
   if (!m_pDocument)
     return DataError;
 
-  const FX_SAFE_INT32 safePage = pdfium::base::checked_cast<int32_t>(dwPage);
-  if (!safePage.IsValid())
-    return DataError;
-
-  if (safePage.ValueOrDie() >= m_pDocument->GetPageCount()) {
+  const int iPage = pdfium::base::checked_cast<int>(dwPage);
+  if (iPage >= m_pDocument->GetPageCount()) {
     // This is XFA page.
     return DataAvailable;
   }
@@ -807,7 +803,7 @@
   const HintsScope hints_scope(GetValidator(), pHints);
   if (m_pLinearized) {
     if (dwPage == m_pLinearized->GetFirstPageNo()) {
-      auto* pPageDict = m_pDocument->GetPageDictionary(safePage.ValueOrDie());
+      auto* pPageDict = m_pDocument->GetPageDictionary(iPage);
       if (!pPageDict)
         return DataError;
 
@@ -858,7 +854,7 @@
   if (CheckAcroForm() == DocFormStatus::FormNotAvailable)
     return DataNotAvailable;
 
-  auto* pPageDict = m_pDocument->GetPageDictionary(safePage.ValueOrDie());
+  auto* pPageDict = m_pDocument->GetPageDictionary(iPage);
   if (!pPageDict)
     return DataError;
 
@@ -993,8 +989,8 @@
 }
 
 bool CPDF_DataAvail::ValidatePage(uint32_t dwPage) const {
-  FX_SAFE_INT32 safePage = pdfium::base::checked_cast<int32_t>(dwPage);
-  auto* pPageDict = m_pDocument->GetPageDictionary(safePage.ValueOrDie());
+  int iPage = pdfium::base::checked_cast<int>(dwPage);
+  auto* pPageDict = m_pDocument->GetPageDictionary(iPage);
   if (!pPageDict)
     return false;
   CPDF_PageObjectAvail obj_avail(GetValidator(), m_pDocument.Get(), pPageDict);