libfreerdp-utils/stream: correctly initialize extended buffer.

This commit is contained in:
Vic Lee 2011-09-07 17:09:40 +08:00
parent 0d412ba629
commit 93d09e1a38

View File

@ -55,13 +55,15 @@ void stream_free(STREAM* stream)
void stream_extend(STREAM* stream, int request_size)
{
int original_size;
int increased_size;
int pos;
pos = stream_get_pos(stream);
increased_size = (request_size > stream->size ? request_size : stream->size);
original_size = stream->size;
increased_size = (request_size > original_size ? request_size : original_size);
stream->size += increased_size;
stream->data = (uint8*)xrealloc(stream->data, stream->size);
memset(stream->data + original_size, 0, increased_size);
stream_set_pos(stream, pos);
memset(stream->p, 0, increased_size);
}