summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2018-07-18 00:56:28 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-07-18 00:56:28 +0000
commit091c0c77fe0e590ecaea993fb0d9e7fb62c8150b (patch)
tree19be4a5cb41df71768e271ec0189700b72ee1560
parent8e0c0dbc4876e661de6c344c759ffe22d3f13bce (diff)
downloadpdfium-091c0c77fe0e590ecaea993fb0d9e7fb62c8150b.tar.xz
Simplify CPDF_Creator::InitID().
Remove checks for impossible conditions. Change-Id: I7a6607675899bfde6179e93da0c9139dfec19984 Reviewed-on: https://pdfium-review.googlesource.com/38070 Reviewed-by: Art Snake <art-snake@yandex-team.ru> Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
-rw-r--r--core/fpdfapi/edit/cpdf_creator.cpp28
1 files changed, 13 insertions, 15 deletions
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<CPDF_Array>();
- const CPDF_Object* pID1 =
- pOldIDArray ? pOldIDArray->GetObjectAt(0) : nullptr;
- if (pID1) {
- m_pIDArray->Add(pID1->Clone());
- } else {
- std::vector<uint8_t> buffer =
- GenerateFileID((uint32_t)(uintptr_t)this, m_dwLastObjNum);
- ByteString bsBuffer(buffer.data(), buffer.size());
- m_pIDArray->AddNew<CPDF_String>(bsBuffer, true);
- }
+ m_pIDArray = pdfium::MakeUnique<CPDF_Array>();
+ 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<uint8_t> buffer =
+ GenerateFileID((uint32_t)(uintptr_t)this, m_dwLastObjNum);
+ ByteString bsBuffer(buffer.data(), buffer.size());
+ m_pIDArray->AddNew<CPDF_String>(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<CPDF_SecurityHandler>();