Fix: dynamic buffer mishandles setting capacity to 0
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Tue, 17 Oct 2017 03:48:21 +0000 (23:48 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Fri, 7 Sep 2018 16:18:16 +0000 (12:18 -0400)
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
src/common/dynamic-buffer.c

index fd39f813b3c2568beec2dff1be91343161ec8517..73195cc2a5586f621314a9b23b55948edec55c40 100644 (file)
@@ -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) {
                /*
This page took 0.025272 seconds and 4 git commands to generate.