]> git.ipfire.org Git - thirdparty/rrdtool-1.x.git/commitdiff
Fix possible memory leak by buffer.file
authorWolfgang Stöggl <c72578@yahoo.de>
Sat, 6 Jul 2019 12:14:28 +0000 (14:14 +0200)
committerTobias Oetiker <tobi@oetiker.ch>
Mon, 8 Jul 2019 07:03:51 +0000 (09:03 +0200)
Close the opened buffer.file in rrd_xport.c before return -1,
if the data processing has failed

- Fixes the following Cppcheck error:
  [rrdtool-1.x/src/rrd_xport.c:435] (error) Memory leak:
  buffer.file [memleak]

src/rrd_xport.c

index 637df8ee3a5470f53a47be458de438fa018e011e..e69a807010175159a6cf232144af406b84136c44 100644 (file)
@@ -432,6 +432,10 @@ int rrd_graph_xport(
 
     /* do the data processing */
     if (rrd_xport_fn(im, &start, &end, &step, &col_cnt, &legend_v, &data, 1)) {
+        /* close the file */
+        if (buffer.file) {
+            fclose(buffer.file);
+        }
         return -1;
     }