aboutsummaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorPierre Ossman <ossman@cendio.se>2020-02-27 13:35:41 +0100
committerPierre Ossman <ossman@cendio.se>2020-02-27 13:35:41 +0100
commit1688e8cd57606f7aaeb0abddc8e9ce3827d253cc (patch)
treefec1b9ceffdfad206b4672a07ee18fb393c82355 /common
parentea85e8b32b238b2c93bd94fe5fb9bba7c519fa88 (diff)
downloadtigervnc-1688e8cd57606f7aaeb0abddc8e9ce3827d253cc.tar.gz
tigervnc-1688e8cd57606f7aaeb0abddc8e9ce3827d253cc.zip
Fix error check for zlib calls
There are multiple "okay" return values, not just Z_OK. Make sure we don't bail out needlessly.
Diffstat (limited to 'common')
-rw-r--r--common/rdr/ZlibInStream.cxx2
-rw-r--r--common/rdr/ZlibOutStream.cxx4
2 files changed, 3 insertions, 3 deletions
diff --git a/common/rdr/ZlibInStream.cxx b/common/rdr/ZlibInStream.cxx
index 9fcfaf6b..0fb3ad1e 100644
--- a/common/rdr/ZlibInStream.cxx
+++ b/common/rdr/ZlibInStream.cxx
@@ -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");
}
diff --git a/common/rdr/ZlibOutStream.cxx b/common/rdr/ZlibOutStream.cxx
index 7a0d692c..99d0617a 100644
--- a/common/rdr/ZlibOutStream.cxx
+++ b/common/rdr/ZlibOutStream.cxx
@@ -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...