Fix CHECK failures with GetFontData() calls.

In an ideal world, like CL [1] assumed, calling GetFontData() twice in a
row would yield the same return value both times. In the real world,
this is not the case and sometimes the call to get font data fails.
Handle the errors that occur in the real world in various CFX_FontMapper
methods that call GetFontData().

Bug: chromium:1372234

[1] https://pdfium-review.googlesource.com/97976

Change-Id: I5bfa6e234c6a2b23a9ef8cf48c31a1a38a7e83ef
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/99351
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
diff --git a/core/fxge/cfx_fontmapper.cpp b/core/fxge/cfx_fontmapper.cpp
index f12b5e2..b8b3917 100644
--- a/core/fxge/cfx_fontmapper.cpp
+++ b/core/fxge/cfx_fontmapper.cpp
@@ -809,7 +809,9 @@
   FixedUninitDataVector<uint8_t> result(required_size);
   size_t actual_size =
       m_pFontInfo->GetFontData(font_handle, 0, result.writable_span());
-  CHECK_EQ(required_size, actual_size);
+  if (actual_size != required_size)
+    return FixedUninitDataVector<uint8_t>();
+
   return result;
 }
 #endif  // PDF_ENABLE_XFA
@@ -825,7 +827,9 @@
     FixedUninitDataVector<uint8_t> font_data(ttc_size);
     size_t size = m_pFontInfo->GetFontData(font_handle, kTableTTCF,
                                            font_data.writable_span());
-    CHECK_EQ(ttc_size, size);
+    if (size != ttc_size)
+      return nullptr;
+
     pFontDesc = m_pFontMgr->AddCachedTTCFontDesc(ttc_size, checksum,
                                                  std::move(font_data));
   }
@@ -856,7 +860,9 @@
     FixedUninitDataVector<uint8_t> font_data(data_size);
     size_t size =
         m_pFontInfo->GetFontData(font_handle, 0, font_data.writable_span());
-    CHECK_EQ(data_size, size);
+    if (size != data_size)
+      return nullptr;
+
     pFontDesc = m_pFontMgr->AddCachedFontDesc(subst_name, weight, is_italic,
                                               std::move(font_data));
   }