diff options
author | tsepez <tsepez@chromium.org> | 2016-11-18 14:48:21 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-11-18 14:48:21 -0800 |
commit | 430ab8363e77c48b2c2435af4d289f85e2be1b96 (patch) | |
tree | c0a9bff16a5b56d607d75c9f415dfc2cce7eb3fd /core/fpdfapi/edit | |
parent | 9053f19d78b6215570029d896c1d62bbb0ce5f7d (diff) | |
download | pdfium-430ab8363e77c48b2c2435af4d289f85e2be1b96.tar.xz |
Add unit test for CXFA_FileRead.
The FileRead's return convention is being modified at
https://codereview.chromium.org/2430743003/, so first provide
a test of the old behaviour.
Fix some issues with null dictionaries as provided by the
CPDF_Stream default ctor along the way.
Review-Url: https://codereview.chromium.org/2517513003
Diffstat (limited to 'core/fpdfapi/edit')
-rw-r--r-- | core/fpdfapi/edit/fpdf_edit_create.cpp | 34 |
1 files changed, 16 insertions, 18 deletions
diff --git a/core/fpdfapi/edit/fpdf_edit_create.cpp b/core/fpdfapi/edit/fpdf_edit_create.cpp index ff12606399..360472948d 100644 --- a/core/fpdfapi/edit/fpdf_edit_create.cpp +++ b/core/fpdfapi/edit/fpdf_edit_create.cpp @@ -417,26 +417,24 @@ CPDF_FlateEncoder::CPDF_FlateEncoder(CPDF_Stream* pStream, bool bFlateEncode) m_bCloned(false), m_bNewData(false) { m_Acc.LoadAllData(pStream, true); - if ((pStream && pStream->GetDict() && - pStream->GetDict()->KeyExist("Filter")) || - !bFlateEncode) { - if (pStream->GetDict()->KeyExist("Filter") && !bFlateEncode) { - CPDF_StreamAcc destAcc; - destAcc.LoadAllData(pStream); - m_dwSize = destAcc.GetSize(); - m_pData = (uint8_t*)destAcc.DetachData(); - m_pDict = ToDictionary(pStream->GetDict()->Clone().release()); - m_pDict->RemoveFor("Filter"); - m_bNewData = true; - m_bCloned = true; - } else { - m_pData = (uint8_t*)m_Acc.GetData(); - m_dwSize = m_Acc.GetSize(); - m_pDict = pStream->GetDict(); - } + bool bHasFilter = pStream && pStream->HasFilter(); + if (bHasFilter && !bFlateEncode) { + CPDF_StreamAcc destAcc; + destAcc.LoadAllData(pStream); + m_dwSize = destAcc.GetSize(); + m_pData = (uint8_t*)destAcc.DetachData(); + m_pDict = ToDictionary(pStream->GetDict()->Clone().release()); + m_pDict->RemoveFor("Filter"); + m_bNewData = true; + m_bCloned = true; + return; + } + if (bHasFilter || !bFlateEncode) { + m_pData = (uint8_t*)m_Acc.GetData(); + m_dwSize = m_Acc.GetSize(); + m_pDict = pStream->GetDict(); return; } - m_bNewData = true; m_bCloned = true; // TODO(thestig): Move to Init() and check return value. |