]> source.dussan.org Git - tigervnc.git/commitdiff
Quick & dirty hack to prevent ZlibOutStream from flushing a non-existent buffer when...
authorDRC <dcommander@users.sourceforge.net>
Tue, 9 Aug 2011 16:22:11 +0000 (16:22 +0000)
committerDRC <dcommander@users.sourceforge.net>
Tue, 9 Aug 2011 16:22:11 +0000 (16:22 +0000)
git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/branches/1_1@4619 3789f03b-4d11-0410-bbf8-ca57d06f2519

common/rdr/ZlibOutStream.cxx
common/rfb/tightEncode.h

index c86a5a5585a1e21c1dc6751c34d6d8ccf554ff80..9ce1a91a5d25bc6e7d12553ca6bc782558f27724 100644 (file)
@@ -79,6 +79,9 @@ void ZlibOutStream::flush()
 
 //    fprintf(stderr,"zos flush: avail_in %d\n",zs->avail_in);
 
+  if (!underlying)
+    throw Exception("ZlibOutStream: underlying OutStream has not been set");
+
   while (zs->avail_in != 0) {
 
     do {
@@ -112,6 +115,9 @@ int ZlibOutStream::overrun(int itemSize, int nItems)
   if (itemSize > bufSize)
     throw Exception("ZlibOutStream overrun: max itemSize exceeded");
 
+  if (!underlying)
+    throw Exception("ZlibOutStream: underlying OutStream has not been set");
+
   while (end - ptr < itemSize) {
     zs->next_in = start;
     zs->avail_in = ptr - start;
index 9877759ad3546321c87b35941ef1c8453f99137a..1a0ea82d00ed3d2800cbbdd4c8c12241de333148 100644 (file)
@@ -196,6 +196,7 @@ static void compressData(rdr::OutStream *os, rdr::ZlibOutStream *zos,
     zos->setCompressionLevel(zlibLevel);
     zos->writeBytes(buf, length);
     zos->flush();
+    zos->setUnderlying(NULL);
     os->writeCompactLength(mem_os.length());
     os->writeBytes(mem_os.data(), mem_os.length());
   }