Check whether the object is a page object before updating |m_PageList|.

bug_1491.in is rendered blank because when handling the "GoTo" action,
the destination points to an object which is a /Pages object instead
of a /Page object. This sets |m_PageList[0]| with the wrong object
which is missing contents.

This CL adds a check for valid page object before updating |m_PageList|
in CPDF_Document::GetPageIndex(), so that when processing the "GoTo"
action, |m_PageList[i]| will remain unchanged for page |i| if the
matching object number doesn't point to a /Page object. Later, during
the rendering process, CPDF_Document::GetPageDictionary() can rely on
TraversePDFPages() to update |m_PageList| with more reliable object
numbers.

Bug: pdfium:1491
Change-Id: I4e8a81c6504f52dd5e5b8cd9195c2c60d8885f94
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/69710
Commit-Queue: Hui Yingst <nigi@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
diff --git a/core/fpdfapi/parser/cpdf_document.cpp b/core/fpdfapi/parser/cpdf_document.cpp
index 76c65b5..e4f246c 100644
--- a/core/fpdfapi/parser/cpdf_document.cpp
+++ b/core/fpdfapi/parser/cpdf_document.cpp
@@ -325,7 +325,9 @@
   if (!pdfium::IndexInBounds(m_PageList, found_index))
     return -1;
 
-  m_PageList[found_index] = objnum;
+  // Only update |m_PageList| when |objnum| points to a /Page object.
+  if (IsValidPageObject(GetOrParseIndirectObject(objnum)))
+    m_PageList[found_index] = objnum;
   return found_index;
 }
 
diff --git a/testing/SUPPRESSIONS b/testing/SUPPRESSIONS
index 0748e66..da51760 100644
--- a/testing/SUPPRESSIONS
+++ b/testing/SUPPRESSIONS
@@ -334,9 +334,6 @@
 # TODO(pdfium:1457): Remove after associated bug is fixed
 bug_1457.in * * *
 
-# TODO(pdfium:1491): Remove after associated bug is fixed
-bug_1491.in * * *
-
 # TODO(pdfium:1519): Remove after associated bug is fixed
 bug_1519.in * * *