Fix a regression in linearized PDFs that have been edited

Unlike regular PDFs, linearized PDFs can have a XRefStm section in the
first page trailer. The spec is not clear. This code was removed in
https://pdfium-review.googlesource.com/118571. Undo that specific change
and add it back.

Bug: 341973428
Change-Id: I48b8bdff191f4c7313f961850dc5023d48ac19e5
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/119530
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Thomas Sepez <tsepez@google.com>
diff --git a/core/fpdfapi/parser/cpdf_parser.cpp b/core/fpdfapi/parser/cpdf_parser.cpp
index f0081a6..b695632 100644
--- a/core/fpdfapi/parser/cpdf_parser.cpp
+++ b/core/fpdfapi/parser/cpdf_parser.cpp
@@ -482,14 +482,16 @@
     return false;
   }
 
+  // Unlike LoadAllCrossRefTablesAndStreams(), the first XRefStm entry in
+  // `xref_stream_list` should be processed.
+  if (xref_stream_list[0] > 0 &&
+      !LoadCrossRefStream(&xref_stream_list[0], /*is_main_xref=*/false)) {
+    return false;
+  }
+
   // Cross reference table entries take precedence over cross reference stream
   // entries. So process the stream entries first and then give the cross
   // reference tables a chance to overwrite them.
-  //
-  // XRefStm entries should only be used in update sections, so skip
-  // `xref_stream_list[0]`.
-  //
-  // See details in ISO 32000-1:2008, section 7.5.8.4.
   for (size_t i = 1; i < xref_list.size(); ++i) {
     if (xref_stream_list[i] > 0 &&
         !LoadCrossRefStream(&xref_stream_list[i], /*is_main_xref=*/false)) {