From 7bc9135cc9e1bcea15754f3493f94bd2fd83eafe Mon Sep 17 00:00:00 2001 From: Andrew Chambers Date: Fri, 3 Sep 2021 13:43:22 +1200 Subject: [PATCH] fix leaks in xport --- src/rrd_tool.c | 11 ++++++++--- src/rrd_xport.c | 2 ++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/rrd_tool.c b/src/rrd_tool.c index 16645cf3..d598cb1d 100644 --- a/src/rrd_tool.c +++ b/src/rrd_tool.c @@ -774,9 +774,14 @@ static int HandleInputLine( rrd_value_t *data; char **legend_v; - rrd_xport - (argc - 1, &argv[1], NULL, &start, &end, &step, &col_cnt, - &legend_v, &data); + if(rrd_xport + (argc - 1, &argv[1], NULL, &start, &end, &step, &col_cnt, + &legend_v, &data) == 0) { + while (col_cnt--) + free(legend_v[col_cnt]); + free(legend_v); + free(data); + } #else rrd_set_error ("the instance of rrdtool has been compiled without graphics"); diff --git a/src/rrd_xport.c b/src/rrd_xport.c index cc401feb..eb814fbc 100644 --- a/src/rrd_xport.c +++ b/src/rrd_xport.c @@ -371,6 +371,8 @@ static int rrd_xport_fn( (rrd_value_t *) malloc((*col_cnt) * row_cnt * sizeof(rrd_value_t))) == NULL) { free(ref_list); + while ((*col_cnt)--) + free(legend_list[*col_cnt]); free(legend_list); rrd_set_error("malloc xport data area"); return (-1); -- 2.47.2