Fix: memory is not zeroed on first set_capacity
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Tue, 17 Oct 2017 21:22:02 +0000 (17:22 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Fri, 24 Aug 2018 19:28:11 +0000 (15:28 -0400)
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
src/common/dynamic-buffer.c

index cec2f1e608a67d1e0a148c491c8a8015ce5f27dc..aef80dded0bab2785820f7cf8acb1f7b9071cf7b 100644 (file)
@@ -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 {
This page took 0.024676 seconds and 4 git commands to generate.