Commit 788f6f7769c9f0b4b439079d87bbc180860fa14c
1 parent
ee93b24d
fix small logic error surrounding adding newlines; in practice, the logic error …
…would probably never manifest itself without other code changes
Showing
1 changed file
with
3 additions
and
3 deletions
libqpdf/QPDFWriter.cc
| @@ -1102,11 +1102,12 @@ QPDFWriter::unparseObject(QPDFObjectHandle object, int level, | @@ -1102,11 +1102,12 @@ QPDFWriter::unparseObject(QPDFObjectHandle object, int level, | ||
| 1102 | writeString("\nstream\n"); | 1102 | writeString("\nstream\n"); |
| 1103 | pushEncryptionFilter(); | 1103 | pushEncryptionFilter(); |
| 1104 | writeBuffer(stream_data); | 1104 | writeBuffer(stream_data); |
| 1105 | + char last_char = this->pipeline->getLastChar(); | ||
| 1105 | popPipelineStack(); | 1106 | popPipelineStack(); |
| 1106 | 1107 | ||
| 1107 | if (this->qdf_mode) | 1108 | if (this->qdf_mode) |
| 1108 | { | 1109 | { |
| 1109 | - if (this->pipeline->getLastChar() != '\n') | 1110 | + if (last_char != '\n') |
| 1110 | { | 1111 | { |
| 1111 | writeString("\n"); | 1112 | writeString("\n"); |
| 1112 | this->added_newline = true; | 1113 | this->added_newline = true; |
| @@ -1776,9 +1777,7 @@ QPDFWriter::writeHintStream(int hint_id) | @@ -1776,9 +1777,7 @@ QPDFWriter::writeHintStream(int hint_id) | ||
| 1776 | openObject(hint_id); | 1777 | openObject(hint_id); |
| 1777 | setDataKey(hint_id); | 1778 | setDataKey(hint_id); |
| 1778 | 1779 | ||
| 1779 | - unsigned char* hs = hint_buffer->getBuffer(); | ||
| 1780 | unsigned long hlen = hint_buffer->getSize(); | 1780 | unsigned long hlen = hint_buffer->getSize(); |
| 1781 | - char last_char = hs[hlen - 1]; | ||
| 1782 | 1781 | ||
| 1783 | writeString("<< /Filter /FlateDecode /S "); | 1782 | writeString("<< /Filter /FlateDecode /S "); |
| 1784 | writeString(QUtil::int_to_string(S)); | 1783 | writeString(QUtil::int_to_string(S)); |
| @@ -1798,6 +1797,7 @@ QPDFWriter::writeHintStream(int hint_id) | @@ -1798,6 +1797,7 @@ QPDFWriter::writeHintStream(int hint_id) | ||
| 1798 | } | 1797 | } |
| 1799 | pushEncryptionFilter(); | 1798 | pushEncryptionFilter(); |
| 1800 | writeBuffer(hint_buffer); | 1799 | writeBuffer(hint_buffer); |
| 1800 | + char last_char = this->pipeline->getLastChar(); | ||
| 1801 | popPipelineStack(); | 1801 | popPipelineStack(); |
| 1802 | 1802 | ||
| 1803 | if (last_char != '\n') | 1803 | if (last_char != '\n') |