2
1
mirror of https://github.com/qpdf/qpdf.git synced 2025-01-09 09:50:28 +00:00

fix small logic error surrounding adding newlines; in practice, the logic error would probably never manifest itself without other code changes

This commit is contained in:
Jay Berkenbilt 2011-08-11 15:22:59 -04:00
parent ee93b24d67
commit 788f6f7769

View File

@ -1102,11 +1102,12 @@ QPDFWriter::unparseObject(QPDFObjectHandle object, int level,
writeString("\nstream\n"); writeString("\nstream\n");
pushEncryptionFilter(); pushEncryptionFilter();
writeBuffer(stream_data); writeBuffer(stream_data);
char last_char = this->pipeline->getLastChar();
popPipelineStack(); popPipelineStack();
if (this->qdf_mode) if (this->qdf_mode)
{ {
if (this->pipeline->getLastChar() != '\n') if (last_char != '\n')
{ {
writeString("\n"); writeString("\n");
this->added_newline = true; this->added_newline = true;
@ -1776,9 +1777,7 @@ QPDFWriter::writeHintStream(int hint_id)
openObject(hint_id); openObject(hint_id);
setDataKey(hint_id); setDataKey(hint_id);
unsigned char* hs = hint_buffer->getBuffer();
unsigned long hlen = hint_buffer->getSize(); unsigned long hlen = hint_buffer->getSize();
char last_char = hs[hlen - 1];
writeString("<< /Filter /FlateDecode /S "); writeString("<< /Filter /FlateDecode /S ");
writeString(QUtil::int_to_string(S)); writeString(QUtil::int_to_string(S));
@ -1798,6 +1797,7 @@ QPDFWriter::writeHintStream(int hint_id)
} }
pushEncryptionFilter(); pushEncryptionFilter();
writeBuffer(hint_buffer); writeBuffer(hint_buffer);
char last_char = this->pipeline->getLastChar();
popPipelineStack(); popPipelineStack();
if (last_char != '\n') if (last_char != '\n')