From 0fc3cb4cd767bca150601a9d07fcdd57e4c50373 Mon Sep 17 00:00:00 2001 From: Denis Pronin Date: Sun, 10 Apr 2022 15:21:06 +0300 Subject: [PATCH] fixed memory leak of not freed jobs_eta in several cases used 'free' function in 'print_thread_status' and in 'show_thread_status_json' functions to free jobs_eta previously allocated Signed-off-by: Denis Pronin --- eta.c | 7 ++++--- stat.c | 2 ++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/eta.c b/eta.c index 17970c78..6017ca31 100644 --- a/eta.c +++ b/eta.c @@ -3,6 +3,7 @@ */ #include #include +#include #ifdef CONFIG_VALGRIND_DEV #include #else @@ -707,10 +708,10 @@ void print_thread_status(void) size_t size; je = get_jobs_eta(false, &size); - if (je) + if (je) { display_thread_status(je); - - free(je); + free(je); + } } void print_status_init(int thr_number) diff --git a/stat.c b/stat.c index 356083e2..949af5ed 100644 --- a/stat.c +++ b/stat.c @@ -1,5 +1,6 @@ #include #include +#include #include #include #include @@ -1698,6 +1699,7 @@ static struct json_object *show_thread_status_json(struct thread_stat *ts, if (je) { json_object_add_value_int(root, "eta", je->eta_sec); json_object_add_value_int(root, "elapsed", je->elapsed_sec); + free(je); } if (opt_list) -- 2.25.1