diff options
Diffstat (limited to 'src/common/torgzip.c')
-rw-r--r-- | src/common/torgzip.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/common/torgzip.c b/src/common/torgzip.c index 5a1e1e8a0..f1771c183 100644 --- a/src/common/torgzip.c +++ b/src/common/torgzip.c @@ -136,6 +136,10 @@ tor_gzip_compress(char **out, size_t *out_len, } done: *out_len = stream->total_out; + if (stream->total_out > out_size + 4097) { + /* If we're wasting more than 4k, don't. */ + tor_realloc(*out, stream->total_out + 1); + } if (deflateEnd(stream)!=Z_OK) { log_warn(LD_BUG, "Error freeing gzip structures"); goto err; |