Free `struct lttng_live_component` if the graph is found to be already
canceled and return the appropriate _END status.
Reported-by: scan-build - Potential leak of memory.
Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: I975e458ed4ce5dc3e50c9bf330a2f6953e5be535
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1308
Tested-by: jenkins
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
static
void lttng_live_component_destroy_data(struct lttng_live_component *lttng_live)
{
static
void lttng_live_component_destroy_data(struct lttng_live_component *lttng_live)
{
+ if (!lttng_live) {
+ return;
+ }
if (lttng_live->params.url) {
g_string_free(lttng_live->params.url, TRUE);
}
if (lttng_live->params.url) {
g_string_free(lttng_live->params.url, TRUE);
}
lttng_live = lttng_live_component_create(params);
if (!lttng_live) {
ret = BT_SELF_COMPONENT_STATUS_NOMEM;
lttng_live = lttng_live_component_create(params);
if (!lttng_live) {
ret = BT_SELF_COMPONENT_STATUS_NOMEM;
}
lttng_live->self_comp = self_comp;
if (lttng_live_graph_is_canceled(lttng_live)) {
}
lttng_live->self_comp = self_comp;
if (lttng_live_graph_is_canceled(lttng_live)) {
+ ret = BT_SELF_COMPONENT_STATUS_END;
+ goto error;
}
ret = bt_self_component_source_add_output_port(
lttng_live->self_comp, "out",
NULL, NULL);
if (ret != BT_SELF_COMPONENT_STATUS_OK) {
}
ret = bt_self_component_source_add_output_port(
lttng_live->self_comp, "out",
NULL, NULL);
if (ret != BT_SELF_COMPONENT_STATUS_OK) {
}
bt_self_component_set_data(
bt_self_component_source_as_self_component(self_comp),
lttng_live);
}
bt_self_component_set_data(
bt_self_component_source_as_self_component(self_comp),
lttng_live);
+error:
+ lttng_live_component_destroy_data(lttng_live);
+ lttng_live = NULL;