X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=libcitadel%2Flib%2Fstringbuf.c;h=ba1c12c173b222e8cefbbbcbf8bc1e0676ebfd0c;hb=442ab8bad1cf7339f746a4b8008bad45757251d0;hp=9b03a0e6c10fc89951a2099717c04eadb19841d4;hpb=3dd90d237c8bc07c71b6b8e5eb2ed9d3e025a8e4;p=citadel.git 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);