From 427d84693052f551da11a175d9a0f74bb6e169b3 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Galarneau?= Date: Wed, 10 Jun 2020 13:02:29 -0400 Subject: [PATCH] common: set dynamic-buffer's data to NULL on reset() MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 Change-Id: I58fd5bbcfcda9d952748bea17430e2f41b076f3c --- src/common/dynamic-buffer.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/common/dynamic-buffer.c b/src/common/dynamic-buffer.c index 26d318dcd..4e87c58ac 100644 --- a/src/common/dynamic-buffer.c +++ b/src/common/dynamic-buffer.c @@ -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 -- 2.34.1