From e9347dad290bd17c81846a6c9dda6e9bc05ead5b Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Galarneau?= Date: Mon, 16 Oct 2017 23:48:21 -0400 Subject: [PATCH] Fix: dynamic buffer mishandles setting capacity to 0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérémie Galarneau --- src/common/dynamic-buffer.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/common/dynamic-buffer.c b/src/common/dynamic-buffer.c index 2e27afa1f..cec2f1e60 100644 --- a/src/common/dynamic-buffer.c +++ b/src/common/dynamic-buffer.c @@ -148,7 +148,8 @@ int lttng_dynamic_buffer_set_capacity(struct lttng_dynamic_buffer *buffer, { int ret = 0; void *new_buf; - size_t new_capacity = round_to_power_of_2(demanded_capacity); + size_t new_capacity = demanded_capacity ? + round_to_power_of_2(demanded_capacity) : 0; if (!buffer || demanded_capacity < buffer->size) { /* -- 2.34.1