octave/octave-gzip.patch

39 lines
1.4 KiB
Diff

--- libinterp/dldfcn/gzip.cc.orig 2016-11-13 08:16:10.000000000 -0700
+++ libinterp/dldfcn/gzip.cc 2016-12-03 07:30:58.000000000 -0700
@@ -348,14 +348,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
@@ -376,8 +380,11 @@
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