Browse Source

Fix error check for zlib calls

There are multiple "okay" return values, not just Z_OK. Make sure we
don't bail out needlessly.
tags/v1.10.90
Pierre Ossman 4 years ago
parent
commit
1688e8cd57
2 changed files with 3 additions and 3 deletions
  1. 1
    1
      common/rdr/ZlibInStream.cxx
  2. 2
    2
      common/rdr/ZlibOutStream.cxx

+ 1
- 1
common/rdr/ZlibInStream.cxx View File

@@ -141,7 +141,7 @@ bool ZlibInStream::decompress(bool wait)
zs->avail_in = bytesIn;

int rc = inflate(zs, Z_SYNC_FLUSH);
if (rc != Z_OK) {
if (rc < 0) {
throw Exception("ZlibInStream: inflate failed");
}


+ 2
- 2
common/rdr/ZlibOutStream.cxx View File

@@ -159,7 +159,7 @@ void ZlibOutStream::deflate(int flush)
#endif

rc = ::deflate(zs, flush);
if (rc != Z_OK) {
if (rc < 0) {
// Silly zlib returns an error if you try to flush something twice
if ((rc == Z_BUF_ERROR) && (flush != Z_NO_FLUSH))
break;
@@ -193,7 +193,7 @@ void ZlibOutStream::checkCompressionLevel()
deflate(Z_SYNC_FLUSH);

rc = deflateParams (zs, newLevel, Z_DEFAULT_STRATEGY);
if (rc != Z_OK) {
if (rc < 0) {
// The implicit flush can result in this error, caused by the
// explicit flush we did above. It should be safe to ignore though
// as the first flush should have left things in a stable state...

Loading…
Cancel
Save