Browse Source

Fix 3305357 (Enabling custom compression level on client crashes server)


git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@4508 3789f03b-4d11-0410-bbf8-ca57d06f2519
tags/v1.1.90
DRC 13 years ago
parent
commit
4b187ad6a2
1 changed files with 8 additions and 6 deletions
  1. 8
    6
      common/rdr/ZlibOutStream.cxx

+ 8
- 6
common/rdr/ZlibOutStream.cxx View File

// fprintf(stderr,"zos flush: calling deflate, avail_in %d, avail_out %d\n", // fprintf(stderr,"zos flush: calling deflate, avail_in %d, avail_out %d\n",
// zs->avail_in,zs->avail_out); // zs->avail_in,zs->avail_out);
checkCompressionLevel(); checkCompressionLevel();
int rc = deflate(zs, Z_SYNC_FLUSH);
if (rc != Z_OK) throw Exception("ZlibOutStream: deflate failed");


// fprintf(stderr,"zos flush: after deflate: %d bytes\n", // fprintf(stderr,"zos flush: after deflate: %d bytes\n",
// zs->next_out-underlying->getptr()); // zs->next_out-underlying->getptr());
// zs->avail_in,zs->avail_out); // zs->avail_in,zs->avail_out);


checkCompressionLevel(); checkCompressionLevel();
int rc = deflate(zs, 0);
if (rc != Z_OK) throw Exception("ZlibOutStream: deflate failed");


// fprintf(stderr,"zos overrun: after deflate: %d bytes\n", // fprintf(stderr,"zos overrun: after deflate: %d bytes\n",
// zs->next_out-underlying->getptr()); // zs->next_out-underlying->getptr());
void ZlibOutStream::checkCompressionLevel() void ZlibOutStream::checkCompressionLevel()
{ {
if (newLevel != compressionLevel) { if (newLevel != compressionLevel) {
if (deflateParams (zs, newLevel, Z_DEFAULT_STRATEGY) != Z_OK) {
int rc = deflate(zs, Z_SYNC_FLUSH);
if (rc != Z_OK)
throw Exception("ZlibOutStream: deflate failed");
if (deflateParams (zs, newLevel, Z_DEFAULT_STRATEGY) != Z_OK)
throw Exception("ZlibOutStream: deflateParams failed"); throw Exception("ZlibOutStream: deflateParams failed");
}
compressionLevel = newLevel; compressionLevel = newLevel;
} else {
int rc = deflate(zs, Z_SYNC_FLUSH);
if (rc != Z_OK)
throw Exception("ZlibOutStream: deflate failed");
} }
} }

Loading…
Cancel
Save