]> granicus.if.org Git - graphviz/commitdiff
Fixed: three memory leaks in neatoinit.c
authorErwin Janssen <erwinjanssen@outlook.com>
Thu, 17 Nov 2016 16:11:13 +0000 (17:11 +0100)
committerErwin Janssen <erwinjanssen@outlook.com>
Wed, 7 Dec 2016 13:52:39 +0000 (14:52 +0100)
In the function `makeGraphData()` memory is allocated in various places,
but not all allocated memory is freed at the end of this function. This
commit fixes this by calling `free()` on the pointers `edges`, `edists`
and `ewgts`.

lib/neatogen/neatoinit.c

index af41582fff0a5acb2561da531af5e36aabd05a2b..b843015c8bd7566ee1e3937804258d31222fc56f 100644 (file)
@@ -772,7 +772,7 @@ static vtx_data *makeGraphData(graph_t * g, int nv, int *nedges, int mode, int m
     vtx_data *graph;
     node_t** nodes;
     int ne = agnedges(g);      /* upper bound */
-    int *edges;
+    int *edges = NULL;
     float *ewgts = NULL;
     node_t *np;
     edge_t *ep;
@@ -914,10 +914,13 @@ static vtx_data *makeGraphData(graph_t * g, int nv, int *nedges, int mode, int m
 
     *nedges = ne;
     if (nodedata)
-       *nodedata = nodes;
+        *nodedata = nodes;
     else
-       free (nodes);
+        free (nodes);
     freePM(ps);
+    free(edges);
+    free(edists);
+    free(ewgts);
     return graph;
 }