From 394e4fc20ec5cee503ad3d0d1fe6fd2cb04c61c3 Mon Sep 17 00:00:00 2001 From: DRC Date: Tue, 9 Aug 2011 16:22:11 +0000 Subject: [PATCH] Quick & dirty hack to prevent ZlibOutStream from flushing a non-existent buffer when it is destructed git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/branches/1_1@4619 3789f03b-4d11-0410-bbf8-ca57d06f2519 --- common/rdr/ZlibOutStream.cxx | 6 ++++++ common/rfb/tightEncode.h | 1 + 2 files changed, 7 insertions(+) diff --git a/common/rdr/ZlibOutStream.cxx b/common/rdr/ZlibOutStream.cxx index c86a5a55..9ce1a91a 100644 --- a/common/rdr/ZlibOutStream.cxx +++ b/common/rdr/ZlibOutStream.cxx @@ -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; diff --git a/common/rfb/tightEncode.h b/common/rfb/tightEncode.h index 9877759a..1a0ea82d 100644 --- a/common/rfb/tightEncode.h +++ b/common/rfb/tightEncode.h @@ -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()); } -- 2.39.5