Fix uninitialized variable access in zlib reported by valgrind. Their web site claims it does no harm ( http://www.zlib.net/zlib_faq.html#faq36 ), but fixing it this way eliminates the problem.

This commit is contained in:
David Cole 2009-11-18 16:47:00 -05:00
parent 5ca6f158d4
commit cf133ff6b3
1 changed files with 7 additions and 0 deletions

View File

@ -285,6 +285,13 @@ int ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy,
s->hash_shift = ((s->hash_bits+MIN_MATCH-1)/MIN_MATCH);
s->window = (Bytef *) ZALLOC(strm, s->w_size, 2*sizeof(Byte));
// The following memset eliminates the valgrind uninitialized warning
// "swept under the carpet" here:
// http://www.zlib.net/zlib_faq.html#faq36
//
memset(s->window, 0, s->w_size*2*sizeof(Byte));
s->prev = (Posf *) ZALLOC(strm, s->w_size, sizeof(Pos));
s->head = (Posf *) ZALLOC(strm, s->hash_size, sizeof(Pos));