]> git.notmuchmail.org Git - notmuch/commit
cli/show: avoid empty write to stdout in format_part_raw
authorDavid Bremner <david@tethera.net>
Sat, 4 May 2019 22:29:08 +0000 (19:29 -0300)
committerDavid Bremner <david@tethera.net>
Sun, 5 May 2019 11:01:17 +0000 (08:01 -0300)
commitae6b52488d71b879e2eb05d5ca6c4d4f641d0558
treefe4979a87e0646b71c69298b93955b2b19d3df6a
parent35addc95aef546db8fee90a181518fedd50148cd
cli/show: avoid empty write to stdout in format_part_raw

Previously if the input was exactly a multiple of the internal buffer
size, notmuch would attempt to fwrite nothing to stdout, but still
expected fwrite to return 1, causing a failure that looked like this:

  $ notmuch show --format=raw id:87o96f1cya.fsf@codeaurora.org
    ...entire message shown as expected..
  Error: Write failed
  $ echo $?
  1

To fix the problem don't call fwrite at all when there's nothing to
write.

Amended by db: add some tests of message sizes likely to cause this
problem.
notmuch-show.c
test/T210-raw.sh