[System] Fix DeflateStream throw on empty flush, double flush. Fixes #28777
compressing.Close ();
backing.Close ();
}
+
+ [Test]
+ public void Bug28777_EmptyFlush ()
+ {
+ MemoryStream backing = new MemoryStream ();
+ DeflateStream compressing = new DeflateStream (backing, CompressionLevel.Fastest, true);
+ compressing.Flush ();
+ compressing.Close ();
+ backing.Close ();
+ }
+
+ [Test]
+ public void Bug28777_DoubleFlush ()
+ {
+ byte[] buffer = new byte [4096];
+ MemoryStream backing = new MemoryStream ();
+ DeflateStream compressing = new DeflateStream (backing, CompressionLevel.Fastest, true);
+ compressing.Write (buffer, 0, buffer.Length);
+ compressing.Flush ();
+ compressing.Flush ();
+ compressing.Close ();
+ backing.Close ();
+ }
}
}
result->gchandle = gchandle;
result->compress = compress;
result->buffer = g_new (guchar, BUFFER_SIZE);
+ result->stream->next_out = result->buffer;
+ result->stream->avail_out = BUFFER_SIZE;
return result;
}
if (!stream->compress)
return 0;
- if (!is_final) {
+ if (!is_final && stream->stream->avail_in != 0) {
status = deflate (stream->stream, Z_PARTIAL_FLUSH);
if (status != Z_OK && status != Z_STREAM_END)
return status;