Commit 0abdf5381c4ecbdaf28e51baade13494dc023dfc

Authored by Jay Berkenbilt
1 parent 76b16591

fix memory error caught by valgrind

Showing 1 changed file with 2 additions and 1 deletions
libqpdf/QPDFWriter.cc
@@ -1778,6 +1778,7 @@ QPDFWriter::writeHintStream(int hint_id) @@ -1778,6 +1778,7 @@ QPDFWriter::writeHintStream(int hint_id)
1778 1778
1779 unsigned char* hs = hint_buffer->getBuffer(); 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];
1781 1782
1782 writeString("<< /Filter /FlateDecode /S "); 1783 writeString("<< /Filter /FlateDecode /S ");
1783 writeString(QUtil::int_to_string(S)); 1784 writeString(QUtil::int_to_string(S));
@@ -1799,7 +1800,7 @@ QPDFWriter::writeHintStream(int hint_id) @@ -1799,7 +1800,7 @@ QPDFWriter::writeHintStream(int hint_id)
1799 writeBuffer(hint_buffer); 1800 writeBuffer(hint_buffer);
1800 popPipelineStack(); 1801 popPipelineStack();
1801 1802
1802 - if (hs[hlen - 1] != '\n') 1803 + if (last_char != '\n')
1803 { 1804 {
1804 writeString("\n"); 1805 writeString("\n");
1805 } 1806 }