summaryrefslogtreecommitdiff
path: root/src/ipcpd/unicast/pol/graph.c
diff options
context:
space:
mode:
authorDimitri Staessens <dimitri@ouroboros.rocks>2020-02-16 16:17:20 +0100
committerSander Vrijders <sander@ouroboros.rocks>2020-02-16 18:33:21 +0100
commita59b71095a84dcbd7c3684639acf3dd3097bd3f2 (patch)
tree639c6f216e141c163b240a9c7edd3fc9e276f303 /src/ipcpd/unicast/pol/graph.c
parentaf8e7f78af9b13c2cf6615dc9eb6c52c51b2bc2c (diff)
downloadouroboros-a59b71095a84dcbd7c3684639acf3dd3097bd3f2.tar.gz
ouroboros-a59b71095a84dcbd7c3684639acf3dd3097bd3f2.zip
ipcpd: Fix double free, memleak and malloc check
Some fixes in the multipath implementation related to memory management that showed up with the static analyzer. Signed-off-by: Dimitri Staessens <dimitri@ouroboros.rocks> Signed-off-by: Sander Vrijders <sander@ouroboros.rocks>
Diffstat (limited to 'src/ipcpd/unicast/pol/graph.c')
-rw-r--r--src/ipcpd/unicast/pol/graph.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/ipcpd/unicast/pol/graph.c b/src/ipcpd/unicast/pol/graph.c
index 1e095ba4..a3689ad6 100644
--- a/src/ipcpd/unicast/pol/graph.c
+++ b/src/ipcpd/unicast/pol/graph.c
@@ -734,14 +734,14 @@ static int graph_routing_table_ecmp(struct graph * graph,
src_v = find_vertex_by_addr(graph, s_addr);
if (src_v == NULL)
- goto fail_dijkstra;
+ goto fail_src_v;
list_for_each(p, &src_v->edges) {
int * tmp_dist;
e = list_entry(p, struct edge, next);
if (dijkstra(graph, e->nb->addr, &nhops, &tmp_dist))
- goto fail_dijkstra;
+ goto fail_src_v;
free(nhops);
@@ -751,7 +751,7 @@ static int graph_routing_table_ecmp(struct graph * graph,
n = malloc(sizeof(*n));
if (n == NULL) {
free(tmp_dist);
- goto fail_dijkstra;
+ goto fail_src_v;
}
n->nhop = e->nb->addr;
list_add_tail(&n->next, &forwarding[v->index]);
@@ -796,9 +796,10 @@ static int graph_routing_table_ecmp(struct graph * graph,
fail_t:
free_routing_table(table);
+ fail_src_v:
+ free(*dist);
fail_dijkstra:
free(forwarding);
- free(*dist);
fail_vertices:
*dist = NULL;
return -1;