From 442ab8bad1cf7339f746a4b8008bad45757251d0 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Wilfried=20G=C3=B6esgens?= Date: Sat, 7 Feb 2009 16:25:35 +0000 Subject: [PATCH] * pad some zeroes before / after compressing so valgrind doesn't get alarmed --- libcitadel/debian/control | 2 +- libcitadel/lib/stringbuf.c | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/libcitadel/debian/control b/libcitadel/debian/control index b4e5be1c0..18ebe2c56 100644 --- a/libcitadel/debian/control +++ b/libcitadel/debian/control @@ -3,7 +3,7 @@ Section: libs Priority: optional Maintainer: Citadel Team Uploaders: Wilfried Goesgens , Alexander Wirt -Build-Depends: debhelper (>= 5) +Build-Depends: debhelper (>= 5), zlib1g-dev Standards-Version: 3.7.3 Homepage: http://citadel.org diff --git a/libcitadel/lib/stringbuf.c b/libcitadel/lib/stringbuf.c index 9b03a0e6c..ba1c12c17 100644 --- a/libcitadel/lib/stringbuf.c +++ b/libcitadel/lib/stringbuf.c @@ -1449,10 +1449,14 @@ int CompressBuffer(StrBuf *Buf) #ifdef HAVE_ZLIB char *compressed_data = NULL; size_t compressed_len, bufsize; + int i = 0; bufsize = compressed_len = ((Buf->BufUsed * 101) / 100) + 100; compressed_data = malloc(compressed_len); + /* Flush some space after the used payload so valgrind shuts up... */ + while ((i < 10) && (Buf->BufUsed + i < Buf->BufSize)) + Buf->buf[Buf->BufUsed + i++] = '\0'; if (compress_gzip((Bytef *) compressed_data, &compressed_len, (Bytef *) Buf->buf, @@ -1462,6 +1466,10 @@ int CompressBuffer(StrBuf *Buf) Buf->buf = compressed_data; Buf->BufUsed = compressed_len; Buf->BufSize = bufsize; + /* Flush some space after the used payload so valgrind shuts up... */ + i = 0; + while ((i < 10) && (Buf->BufUsed + i < Buf->BufSize)) + Buf->buf[Buf->BufUsed + i++] = '\0'; return 1; } else { free(compressed_data); -- 2.30.2