Assert CPDF_Image::m_pDocument is never nullptr.

Remove a check that will never be true.

Change-Id: I6474cb7f6549f412a368d1920fd0af90eae9a700
Reviewed-on: https://pdfium-review.googlesource.com/c/44540
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
diff --git a/core/fpdfapi/page/cpdf_image.cpp b/core/fpdfapi/page/cpdf_image.cpp
index 89bcd3f..ec4f414 100644
--- a/core/fpdfapi/page/cpdf_image.cpp
+++ b/core/fpdfapi/page/cpdf_image.cpp
@@ -42,11 +42,14 @@
   return bpc == 1 || bpc == 2 || bpc == 4 || bpc == 8 || bpc == 16;
 }
 
-CPDF_Image::CPDF_Image(CPDF_Document* pDoc) : m_pDocument(pDoc) {}
+CPDF_Image::CPDF_Image(CPDF_Document* pDoc) : m_pDocument(pDoc) {
+  ASSERT(m_pDocument);
+}
 
 CPDF_Image::CPDF_Image(CPDF_Document* pDoc,
                        std::unique_ptr<CPDF_Stream> pStream)
     : m_bIsInline(true), m_pDocument(pDoc), m_pStream(std::move(pStream)) {
+  ASSERT(m_pDocument);
   ASSERT(m_pStream.IsOwned());
   FinishInitialization(m_pStream->GetDict());
 }
@@ -54,11 +57,12 @@
 CPDF_Image::CPDF_Image(CPDF_Document* pDoc, uint32_t dwStreamObjNum)
     : m_pDocument(pDoc),
       m_pStream(ToStream(pDoc->GetIndirectObject(dwStreamObjNum))) {
+  ASSERT(m_pDocument);
   ASSERT(!m_pStream.IsOwned());
   FinishInitialization(m_pStream->GetDict());
 }
 
-CPDF_Image::~CPDF_Image() {}
+CPDF_Image::~CPDF_Image() = default;
 
 void CPDF_Image::FinishInitialization(CPDF_Dictionary* pStreamDict) {
   m_pOC = pStreamDict->GetDictFor("OC");
diff --git a/core/fpdfapi/page/cpdf_imageobject.cpp b/core/fpdfapi/page/cpdf_imageobject.cpp
index 2b3d7b0..4da0bf9 100644
--- a/core/fpdfapi/page/cpdf_imageobject.cpp
+++ b/core/fpdfapi/page/cpdf_imageobject.cpp
@@ -57,11 +57,7 @@
   if (!m_pImage)
     return;
 
-  CPDF_Document* pDocument = m_pImage->GetDocument();
-  if (!pDocument)
-    return;
-
-  CPDF_DocPageData* pPageData = pDocument->GetPageData();
+  CPDF_DocPageData* pPageData = m_pImage->GetDocument()->GetPageData();
   if (!pPageData)
     return;