test-istream.c (dovecot-2.3.16) | : | test-istream.c (dovecot-2.3.17) | ||
---|---|---|---|---|
skipping to change at line 66 | skipping to change at line 66 | |||
buffer size so valgrind can catch read overflows. If a | buffer size so valgrind can catch read overflows. If a | |||
correctly sized memarea already exists, use it only if | correctly sized memarea already exists, use it only if | |||
its refcount is 1. Otherwise with refcount>1 we could be | its refcount is 1. Otherwise with refcount>1 we could be | |||
moving data within an existing memarea, which breaks | moving data within an existing memarea, which breaks | |||
snapshots. */ | snapshots. */ | |||
if (cur_max > 0 && (stream->buffer_size != cur_max || | if (cur_max > 0 && (stream->buffer_size != cur_max || | |||
stream->memarea == NULL || | stream->memarea == NULL || | |||
memarea_get_refcount(stream->memarea) > 1)) { | memarea_get_refcount(stream->memarea) > 1)) { | |||
void *old_w_buffer = stream->w_buffer; | void *old_w_buffer = stream->w_buffer; | |||
stream->w_buffer = i_malloc(cur_max); | stream->w_buffer = i_malloc(cur_max); | |||
memcpy(stream->w_buffer, old_w_buffer, | if (stream->buffer_size != 0) { | |||
I_MIN(stream->buffer_size, cur_max)); | memcpy(stream->w_buffer, old_w_buffer, | |||
I_MIN(stream->buffer_size, cur_max)); | ||||
} | ||||
stream->buffer = stream->w_buffer; | stream->buffer = stream->w_buffer; | |||
stream->buffer_size = cur_max; | stream->buffer_size = cur_max; | |||
if (stream->memarea != NULL) | if (stream->memarea != NULL) | |||
memarea_unref(&stream->memarea); | memarea_unref(&stream->memarea); | |||
stream->memarea = memarea_init(stream->w_buffer, | stream->memarea = memarea_init(stream->w_buffer, | |||
stream->buffer_size, | stream->buffer_size, | |||
test_buffer_free, | test_buffer_free, | |||
stream->w_buffer); | stream->w_buffer); | |||
} | } | |||
End of changes. 1 change blocks. | ||||
2 lines changed or deleted | 4 lines changed or added |