common: set dynamic-buffer's data to NULL on reset()
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Wed, 10 Jun 2020 17:02:29 +0000 (13:02 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Wed, 10 Jun 2020 21:30:49 +0000 (17:30 -0400)
Set 'data' to NULL after the reset of a dynamic_buffer since
re-using it (e.g. appending) will cause realloc to be called
with an invalid pointer.

Not marked as a fix as no code currently re-uses a buffer after
a reset().

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I58fd5bbcfcda9d952748bea17430e2f41b076f3c

src/common/dynamic-buffer.c

index 26d318dcdf3c1a3ec6d570b0de3d26a58bd37d36..4e87c58ac1b43778cee695bbe2f78596b99d3f8d 100644 (file)
@@ -186,6 +186,7 @@ void lttng_dynamic_buffer_reset(struct lttng_dynamic_buffer *buffer)
        buffer->size = 0;
        buffer->_capacity = 0;
        free(buffer->data);
+       buffer->data = NULL;
 }
 
 LTTNG_HIDDEN
This page took 0.026323 seconds and 4 git commands to generate.