Fix unintialized value bug in gzputc() introduced by const patches.

Avoid the use of an uninitialized value when the write buffers have
not been initialized.  A recent change to avoid the use of strm->
next_in in order to resolve some const conflicts added the use of
state->in in its place.  This patch avoids the use of state->in
when it is not initialized.  Nothing bad would actually happen,
since two variables set to the same unintialized value are
subtracted.  However valgrind was rightly complaining.  So this
fixes that.
This commit is contained in:
Mark Adler 2012-08-24 15:02:28 -07:00
parent 17068938ce
commit aa566e86c4
1 changed files with 10 additions and 8 deletions

View File

@ -270,14 +270,16 @@ int ZEXPORT gzputc(file, c)
/* try writing to input buffer for speed (state->size == 0 if buffer not /* try writing to input buffer for speed (state->size == 0 if buffer not
initialized) */ initialized) */
if (strm->avail_in == 0) if (state->size) {
strm->next_in = state->in; if (strm->avail_in == 0)
have = strm->next_in + strm->avail_in - state->in; strm->next_in = state->in;
if (have < state->size) { have = strm->next_in + strm->avail_in - state->in;
state->in[have] = c; if (have < state->size) {
strm->avail_in++; state->in[have] = c;
state->x.pos++; strm->avail_in++;
return c & 0xff; state->x.pos++;
return c & 0xff;
}
} }
/* no room in buffer or not initialized, use gz_write() */ /* no room in buffer or not initialized, use gz_write() */