From fbec801a8dd8ac30dc2f08385deb0ac81031f3f5 Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Tue, 19 Dec 2017 18:12:13 +0000 Subject: Change pattern creation checks in CPDF_DocPageData::GetPattern(). Do them in the right places, instead of having a catch-all at the end. Change-Id: Ie26f06dbd1c50d5b5bf57aa1f9993d5d19f74c02 Reviewed-on: https://pdfium-review.googlesource.com/21670 Reviewed-by: Henrique Nakashima Commit-Queue: Lei Zhang --- core/fpdfapi/page/cpdf_docpagedata.cpp | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'core') diff --git a/core/fpdfapi/page/cpdf_docpagedata.cpp b/core/fpdfapi/page/cpdf_docpagedata.cpp index dc2554f92d..0d2a9189b6 100644 --- a/core/fpdfapi/page/cpdf_docpagedata.cpp +++ b/core/fpdfapi/page/cpdf_docpagedata.cpp @@ -346,19 +346,20 @@ CPDF_Pattern* CPDF_DocPageData::GetPattern(CPDF_Object* pPatternObj, m_pPDFDoc.Get(), pPatternObj, true, matrix); } else { CPDF_Dictionary* pDict = pPatternObj->GetDict(); - if (pDict) { - int type = pDict->GetIntegerFor("PatternType"); - if (type == CPDF_Pattern::TILING) { - pPattern = pdfium::MakeUnique(m_pPDFDoc.Get(), - pPatternObj, matrix); - } else if (type == CPDF_Pattern::SHADING) { - pPattern = pdfium::MakeUnique( - m_pPDFDoc.Get(), pPatternObj, false, matrix); - } + if (!pDict) + return nullptr; + + int type = pDict->GetIntegerFor("PatternType"); + if (type == CPDF_Pattern::TILING) { + pPattern = pdfium::MakeUnique(m_pPDFDoc.Get(), + pPatternObj, matrix); + } else if (type == CPDF_Pattern::SHADING) { + pPattern = pdfium::MakeUnique( + m_pPDFDoc.Get(), pPatternObj, false, matrix); + } else { + return nullptr; } } - if (!pPattern) - return nullptr; if (ptData) { ptData->reset(std::move(pPattern)); -- cgit v1.2.3