summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2018-10-24 21:33:31 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-10-24 21:33:31 +0000
commit9cbc37b4a5bfb3932e5f9a50c552d7b913178337 (patch)
tree55ddae8b49dd2d1121a11e3666193edb6e1ce69c
parente835574db56d3a59f444fa98318458d83ffe15a4 (diff)
downloadpdfium-9cbc37b4a5bfb3932e5f9a50c552d7b913178337.tar.xz
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>
-rw-r--r--core/fpdfapi/page/cpdf_image.cpp8
-rw-r--r--core/fpdfapi/page/cpdf_imageobject.cpp6
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<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,
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;