From 11c2e97d51ad0e6d2b73067f0aabf83f61fb80d5 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Sun, 18 Jun 2006 09:03:48 +0000 Subject: [PATCH] Another _zlib fix. svn:r6652 --- src/or/buffers.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/or/buffers.c b/src/or/buffers.c index 872e40994d..e1ec60edd7 100644 --- a/src/or/buffers.c +++ b/src/or/buffers.c @@ -1296,7 +1296,8 @@ write_to_buf_zlib(buf_t *buf, tor_zlib_state_t *state, { char *next; size_t old_avail, avail; - while (1) { + int over = 0; + while (!over) { buf_ensure_capacity(buf, buf->datalen + 1024); next = _buf_end(buf); if (next < buf->cur) @@ -1305,12 +1306,13 @@ write_to_buf_zlib(buf_t *buf, tor_zlib_state_t *state, old_avail = avail = (buf->mem + buf->datalen) - buf->cur; switch (tor_zlib_process(state, &next, &avail, &data, &data_len, done)) { case TOR_ZLIB_DONE: - return 0; + over = 1; + break; case TOR_ZLIB_ERR: return -1; case TOR_ZLIB_OK: if (data_len == 0) - return 0; + over = 1; break; case TOR_ZLIB_BUF_FULL: if (avail && buf->len >= 1024 + buf->datalen) { @@ -1335,6 +1337,8 @@ write_to_buf_zlib(buf_t *buf, tor_zlib_state_t *state, if (buf->datalen > buf->highwater) buf->highwater = buf->datalen; buf_total_used += old_avail - avail; + if (over) + return 0; } }