From 6a119fb353ec862151543489201b20f67628a6f2 Mon Sep 17 00:00:00 2001 From: Sander Vrijders Date: Fri, 24 Mar 2017 11:40:30 +0100 Subject: ipcpd: normal: Fix negative malloc This adds a check to prevent a negative malloc in case the graph structure is empty. --- src/ipcpd/normal/graph.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/ipcpd/normal') diff --git a/src/ipcpd/normal/graph.c b/src/ipcpd/normal/graph.c index ecaff14c..b3e105e3 100644 --- a/src/ipcpd/normal/graph.c +++ b/src/ipcpd/normal/graph.c @@ -235,6 +235,8 @@ int graph_add_edge(struct graph * graph, pthread_mutex_unlock(&graph->lock); + log_dbg("Added an edge to the graph."); + return 0; } @@ -268,6 +270,8 @@ int graph_update_edge(struct graph * graph, pthread_mutex_unlock(&graph->lock); + log_dbg("Updated an edge of the graph."); + return 0; } @@ -315,6 +319,8 @@ int graph_del_edge(struct graph * graph, pthread_mutex_unlock(&graph->lock); + log_dbg("Removed an edge of the graph."); + return 0; } @@ -453,6 +459,11 @@ ssize_t graph_routing_table(struct graph * graph, pthread_mutex_lock(&graph->lock); + if (graph->nr_vertices == 0) { + pthread_mutex_unlock(&graph->lock); + return 0; + } + prevs = dijkstra(graph, s_addr); if (prevs == NULL) { pthread_mutex_unlock(&graph->lock); -- cgit v1.2.3