From: Jérémie Galarneau Date: Tue, 17 Oct 2017 21:22:02 +0000 (-0400) Subject: Fix: memory is not zeroed on first set_capacity X-Git-Tag: v2.11.0-rc1~93 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=6ee96b4d634b95f8cb91537515016246638189e4;p=lttng-tools.git Fix: memory is not zeroed on first set_capacity Signed-off-by: Jérémie Galarneau --- diff --git a/src/common/dynamic-buffer.c b/src/common/dynamic-buffer.c index cec2f1e60..aef80dded 100644 --- a/src/common/dynamic-buffer.c +++ b/src/common/dynamic-buffer.c @@ -108,22 +108,12 @@ int lttng_dynamic_buffer_set_size(struct lttng_dynamic_buffer *buffer, } if (new_size > buffer->_capacity) { - size_t original_size = buffer->size; - size_t original_capacity = buffer->_capacity; - ret = lttng_dynamic_buffer_set_capacity(buffer, new_size); if (ret) { goto end; } - /* - * Zero-initialize the space that was left in the buffer at the - * before we increased its capacity (original capacity - original size). - * The newly acquired capacity (new capacity - original capacity) - * is zeroed by lttng_dynamic_buffer_set_capacity(). - */ - memset(buffer->data + original_size, 0, - original_capacity - original_size); + memset(buffer->data + buffer->size, 0, new_size - buffer->size); } else if (new_size > buffer->size) { memset(buffer->data + buffer->size, 0, new_size - buffer->size); } else {