From 091c0c77fe0e590ecaea993fb0d9e7fb62c8150b Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Wed, 18 Jul 2018 00:56:28 +0000 Subject: Simplify CPDF_Creator::InitID(). Remove checks for impossible conditions. Change-Id: I7a6607675899bfde6179e93da0c9139dfec19984 Reviewed-on: https://pdfium-review.googlesource.com/38070 Reviewed-by: Art Snake Reviewed-by: Henrique Nakashima Commit-Queue: Lei Zhang --- core/fpdfapi/edit/cpdf_creator.cpp | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) (limited to 'core/fpdfapi') diff --git a/core/fpdfapi/edit/cpdf_creator.cpp b/core/fpdfapi/edit/cpdf_creator.cpp index 94b8608c71..f5d8c0fe49 100644 --- a/core/fpdfapi/edit/cpdf_creator.cpp +++ b/core/fpdfapi/edit/cpdf_creator.cpp @@ -711,21 +711,18 @@ bool CPDF_Creator::Create(uint32_t flags) { } void CPDF_Creator::InitID() { - const CPDF_Array* pOldIDArray = m_pParser ? m_pParser->GetIDArray() : nullptr; + ASSERT(!m_pIDArray); - bool idArrayPreExisting = !!m_pIDArray; - if (!idArrayPreExisting) { - m_pIDArray = pdfium::MakeUnique(); - const CPDF_Object* pID1 = - pOldIDArray ? pOldIDArray->GetObjectAt(0) : nullptr; - if (pID1) { - m_pIDArray->Add(pID1->Clone()); - } else { - std::vector buffer = - GenerateFileID((uint32_t)(uintptr_t)this, m_dwLastObjNum); - ByteString bsBuffer(buffer.data(), buffer.size()); - m_pIDArray->AddNew(bsBuffer, true); - } + m_pIDArray = pdfium::MakeUnique(); + const CPDF_Array* pOldIDArray = m_pParser ? m_pParser->GetIDArray() : nullptr; + const CPDF_Object* pID1 = pOldIDArray ? pOldIDArray->GetObjectAt(0) : nullptr; + if (pID1) { + m_pIDArray->Add(pID1->Clone()); + } else { + std::vector buffer = + GenerateFileID((uint32_t)(uintptr_t)this, m_dwLastObjNum); + ByteString bsBuffer(buffer.data(), buffer.size()); + m_pIDArray->AddNew(bsBuffer, true); } if (pOldIDArray) { @@ -742,7 +739,8 @@ void CPDF_Creator::InitID() { } m_pIDArray->Add(m_pIDArray->GetObjectAt(0)->Clone()); - if (m_pEncryptDict && !pOldIDArray && m_pParser && !idArrayPreExisting) { + if (m_pEncryptDict) { + ASSERT(m_pParser); if (m_pEncryptDict->GetStringFor("Filter") == "Standard") { ByteString user_pass = m_pParser->GetPassword(); m_pSecurityHandler = pdfium::MakeUnique(); -- cgit v1.2.3