Revert "Remove some checks that are never true in patterns code."

This reverts commit 3ec52874da605fe3a28eadaebec47d6e86da4fa5.

Reason for revert: https://crbug.com/904726

Original change's description:
> Remove some checks that are never true in patterns code.
>
> Change-Id: I8f589c1fa91d140e11d6ee4edd02daa30d224ac3
> Reviewed-on: https://pdfium-review.googlesource.com/c/45190
> Reviewed-by: Tom Sepez <tsepez@chromium.org>
> Commit-Queue: Lei Zhang <thestig@chromium.org>

TBR=thestig@chromium.org,tsepez@chromium.org
BUG=chromium:904726

# Not skipping CQ checks because original CL landed > 1 day ago.

Change-Id: I00dd954f5b2381efddc23f7a406c36d7e788910a
Reviewed-on: https://pdfium-review.googlesource.com/c/45510
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
diff --git a/core/fpdfapi/page/cpdf_docpagedata.cpp b/core/fpdfapi/page/cpdf_docpagedata.cpp
index eaadc96..7b62467 100644
--- a/core/fpdfapi/page/cpdf_docpagedata.cpp
+++ b/core/fpdfapi/page/cpdf_docpagedata.cpp
@@ -342,9 +342,8 @@
 CPDF_Pattern* CPDF_DocPageData::GetPattern(CPDF_Object* pPatternObj,
                                            bool bShading,
                                            const CFX_Matrix& matrix) {
-  ASSERT(pPatternObj);
-  ASSERT(pPatternObj->IsDictionary() || pPatternObj->IsStream());
-  ASSERT(pPatternObj->GetDict());
+  if (!pPatternObj)
+    return nullptr;
 
   CPDF_CountedPattern* ptData = nullptr;
   auto it = m_PatternMap.find(pPatternObj);
@@ -360,6 +359,9 @@
         m_pPDFDoc.Get(), pPatternObj, true, matrix);
   } else {
     CPDF_Dictionary* pDict = pPatternObj->GetDict();
+    if (!pDict)
+      return nullptr;
+
     int type = pDict->GetIntegerFor("PatternType");
     if (type == CPDF_Pattern::TILING) {
       pPattern = pdfium::MakeUnique<CPDF_TilingPattern>(m_pPDFDoc.Get(),
diff --git a/core/fpdfapi/page/cpdf_tilingpattern.cpp b/core/fpdfapi/page/cpdf_tilingpattern.cpp
index ce01d8a..faa7eb8 100644
--- a/core/fpdfapi/page/cpdf_tilingpattern.cpp
+++ b/core/fpdfapi/page/cpdf_tilingpattern.cpp
@@ -36,6 +36,9 @@
     return true;
 
   const CPDF_Dictionary* pDict = pattern_obj()->GetDict();
+  if (!pDict)
+    return false;
+
   m_bColored = pDict->GetIntegerFor("PaintType") == 1;
   m_XStep = static_cast<float>(fabs(pDict->GetNumberFor("XStep")));
   m_YStep = static_cast<float>(fabs(pDict->GetNumberFor("YStep")));