diff --git a/src/bin/lttng/utils.c b/src/bin/lttng/utils.c index 28b007b240..8acca7d864 100644 --- a/src/bin/lttng/utils.c +++ b/src/bin/lttng/utils.c @@ -468,8 +468,8 @@ void print_session_stats(const char *session_name) int get_session_stats_str(const char *session_name, char **out_str) { int count, nb_domains, domain_idx, channel_idx, session_idx, ret; - struct lttng_domain *domains; - struct lttng_channel *channels; + struct lttng_domain *domains = NULL; + struct lttng_channel *channels = NULL; uint64_t discarded_events_total = 0, lost_packets_total = 0; struct lttng_session *sessions = NULL; const struct lttng_session *selected_session = NULL; @@ -511,6 +511,8 @@ int get_session_stats_str(const char *session_name, char **out_str) goto end; } + free(channels); + channels = NULL; count = lttng_list_channels(handle, &channels); for (channel_idx = 0; channel_idx < count; channel_idx++) { uint64_t discarded_events = 0, lost_packets = 0; @@ -572,6 +574,8 @@ int get_session_stats_str(const char *session_name, char **out_str) } end: free(sessions); + free(channels); + free(domains); return ret; }