From 9cbc37b4a5bfb3932e5f9a50c552d7b913178337 Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Wed, 24 Oct 2018 21:33:31 +0000 Subject: 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 Commit-Queue: Lei Zhang --- core/fpdfapi/page/cpdf_image.cpp | 8 ++++++-- core/fpdfapi/page/cpdf_imageobject.cpp | 6 +----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/core/fpdfapi/page/cpdf_image.cpp b/core/fpdfapi/page/cpdf_image.cpp index 89bcd3fa7b..ec4f414423 100644 --- a/core/fpdfapi/page/cpdf_image.cpp +++ b/core/fpdfapi/page/cpdf_image.cpp @@ -42,11 +42,14 @@ bool CPDF_Image::IsValidJpegBitsPerComponent(int32_t bpc) { 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 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, 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 2b3d7b0de3..4da0bf9b95 100644 --- a/core/fpdfapi/page/cpdf_imageobject.cpp +++ b/core/fpdfapi/page/cpdf_imageobject.cpp @@ -57,11 +57,7 @@ void CPDF_ImageObject::MaybePurgeCache() { 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; -- cgit v1.2.3