diff options
Diffstat (limited to 'core/fpdfapi/edit')
-rw-r--r-- | core/fpdfapi/edit/cpdf_creator.cpp | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/core/fpdfapi/edit/cpdf_creator.cpp b/core/fpdfapi/edit/cpdf_creator.cpp index 1c0cd69a4b..858d56cbaf 100644 --- a/core/fpdfapi/edit/cpdf_creator.cpp +++ b/core/fpdfapi/edit/cpdf_creator.cpp @@ -171,13 +171,21 @@ bool CPDF_Creator::WriteStream(const CPDF_Object* pStream, encoder.GetDict()->SetNewFor<CPDF_Number>( "Length", static_cast<int>(encryptor.GetSize())); } + if (!WriteDirectObj(objnum, encoder.GetDict(), true) || - !m_Archive->WriteString("stream\r\n") || - !m_Archive->WriteBlock(encryptor.GetData(), encryptor.GetSize()) || - !m_Archive->WriteString("\r\nendstream")) { + !m_Archive->WriteString("stream\r\n")) { + return false; + } + + // Allow for empty streams. + if (encryptor.GetSize() > 0 && + !m_Archive->WriteBlock(encryptor.GetData(), encryptor.GetSize())) { return false; } + if (!m_Archive->WriteString("\r\nendstream")) + return false; + return true; } |