Initialise zlib input data to nothing on socket flush.

Fixes possible crash in zlib deflate routines when flushing sockets before any data has
been written to the socket.

Seems to be reproducible if applying the following tmp queue commit, hosting a game, and
joining it.
master
Cyp 2012-03-16 14:34:45 +01:00
parent fbc600ecdf
commit 2b3362bd0e
1 changed files with 2 additions and 0 deletions

View File

@ -627,6 +627,8 @@ void socketFlush(Socket *sock)
// Flush data out of zlib compression state.
do
{
sock->zDeflate.next_in = (Bytef *)NULL;
sock->zDeflate.avail_in = 0;
size_t alreadyHave = sock->zDeflateOutBuf.size();
sock->zDeflateOutBuf.resize(alreadyHave + 1000); // 100 bytes would probably be enough to flush the rest in one go.
sock->zDeflate.next_out = (Bytef *)&sock->zDeflateOutBuf[alreadyHave];