Fix: liblttng-ctl: erroneous flat size computation
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Fri, 4 Mar 2022 20:29:12 +0000 (15:29 -0500)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Tue, 8 Mar 2022 19:20:58 +0000 (14:20 -0500)
compute_flattened_size() erroneously computes (over-estimates) the size
of the allocation required to hold the flat array of struct lttng_event
returned to the user by lttng_list_{events, syscalls, tracepoints}.

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

src/common/event.cpp

index 8e1b99ff902fb5dd91989840ade2ffc483afc170..dda5eb7ba71176df9d0233d24742f58aed7e2908 100644 (file)
@@ -1488,6 +1488,9 @@ static enum lttng_error_code compute_flattened_size(
        /* The basic struct lttng_event */
        storage_req = event_count * sizeof(struct lttng_event);
 
+       /* The struct·lttng_event_extended */
+       storage_req += event_count * sizeof(struct lttng_event_extended);
+
        for (i = 0; i < event_count; i++) {
                int probe_storage_req = 0;
                const struct event_list_element *element = (const struct event_list_element *)
@@ -1508,10 +1511,6 @@ static enum lttng_error_code compute_flattened_size(
                        probe_storage_req = ret;
                }
 
-               /* The struct·lttng_event_extended */
-               storage_req += event_count *
-                       sizeof(struct lttng_event_extended);
-
                if (element->filter_expression) {
                        storage_req += strlen(element->filter_expression) + 1;
                }
This page took 0.025906 seconds and 4 git commands to generate.