ZlibInStream must be reset after use, or we will end up with
"Rectangle too big" crashes sooner or later. (A good testcase is to
run "/usr/X11R6/lib/xscreensaver/attraction -mode splines" over a slow
connection.)


git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@48 3789f03b-4d11-0410-bbf8-ca57d06f2519
diff --git a/rfb/tightDecode.h b/rfb/tightDecode.h
index 02589c9..c707ea1 100644
--- a/rfb/tightDecode.h
+++ b/rfb/tightDecode.h
@@ -153,12 +153,13 @@
   // Determine if the data should be decompressed or just copied.
   int rowSize = (r.width() * bppp + 7) / 8;
   int dataSize = r.height() * rowSize;
+  int streamId = -1;
   rdr::InStream *input;
   if (dataSize < TIGHT_MIN_TO_COMPRESS) {
     input = is;
   } else {
     int length = is->readCompactLength();
-    int streamId = comp_ctl & 0x03;
+    streamId = comp_ctl & 0x03;
     zis[streamId].setUnderlying(is, length);
     input = &zis[streamId];
   }
@@ -216,6 +217,10 @@
   }
 
   IMAGE_RECT(r, buf);
+
+  if (streamId != -1) {
+    zis[streamId].reset();
+  }
 }
 
 static bool