From: Jérémie Galarneau Date: Tue, 17 Oct 2017 03:48:21 +0000 (-0400) Subject: Fix: dynamic buffer mishandles setting capacity to 0 X-Git-Tag: v2.10.6~47 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=093627be892001471417cd94ab307f14377a032a;p=lttng-tools.git Fix: dynamic buffer mishandles setting capacity to 0 Signed-off-by: Jérémie Galarneau --- diff --git a/src/common/dynamic-buffer.c b/src/common/dynamic-buffer.c index fd39f813b..73195cc2a 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) { /*