]> git.ipfire.org Git - thirdparty/rrdtool-1.x.git/commitdiff
fix leaks in xport 1132/head
authorAndrew Chambers <ac@acha.ninja>
Fri, 3 Sep 2021 01:43:22 +0000 (13:43 +1200)
committerAndrew Chambers <ac@acha.ninja>
Fri, 3 Sep 2021 01:47:58 +0000 (13:47 +1200)
src/rrd_tool.c
src/rrd_xport.c

index 16645cf3ff8de6d4585e941a5a9a3fada2d97cf9..d598cb1d691e361d9e59511e19b6e27dbb59f5b8 100644 (file)
@@ -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");
index cc401feb9cbed8246cc41de9816a72c9e4f38f5e..eb814fbcb00206f2c2fdc5a6a17890beee27d0ca 100644 (file)
@@ -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);