Mercurial > octave
changeset 22923:b150be19734d
maint: periodic merge of stable to default.
author | Rik <rik@octave.org> |
---|---|
date | Sun, 18 Dec 2016 07:10:20 -0800 |
parents | b28801182c08 (current diff) 426325aa8ee9 (diff) |
children | 509b2ef72225 |
files | libinterp/dldfcn/gzip.cc |
diffstat | 1 files changed, 13 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/libinterp/dldfcn/gzip.cc Sat Dec 17 11:10:22 2016 -0500 +++ b/libinterp/dldfcn/gzip.cc Sun Dec 18 07:10:20 2016 -0800 @@ -355,14 +355,18 @@ unsigned char buf_in[buf_len]; unsigned char buf_out[buf_len]; - while ((strm->avail_in = std::fread (buf_in, sizeof (buf_in[0]), - buf_len, source.fp)) != 0) + int flush; + + do { + strm->avail_in = std::fread (buf_in, sizeof (buf_in[0]), + buf_len, source.fp); + if (std::ferror (source.fp)) throw std::runtime_error ("failed to read source file"); strm->next_in = buf_in; - const int flush = std::feof (source.fp) ? Z_FINISH : Z_NO_FLUSH; + flush = std::feof (source.fp) ? Z_FINISH : Z_NO_FLUSH; // If deflate returns Z_OK and with zero avail_out, it must be // called again after making room in the output buffer because @@ -383,8 +387,12 @@ while (strm->avail_out == 0); if (strm->avail_in != 0) - throw std::runtime_error ("failed to wrote file"); - } + throw std::runtime_error ("failed to write file"); + + } while (flush != Z_FINISH); + + if (status != Z_STREAM_END) + throw std::runtime_error ("failed to write file"); } void