From: Andrew Chambers Date: Fri, 3 Sep 2021 01:43:22 +0000 (+1200) Subject: fix leaks in xport X-Git-Tag: v1.8.0~18^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F1132%2Fhead;p=thirdparty%2Frrdtool-1.x.git fix leaks in xport --- 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);