diff options
author | Sander Vrijders <[email protected]> | 2017-03-24 11:40:30 +0100 |
---|---|---|
committer | Sander Vrijders <[email protected]> | 2017-03-24 11:40:30 +0100 |
commit | 6a119fb353ec862151543489201b20f67628a6f2 (patch) | |
tree | 8449518cff92a5678f3e36e3d1c6b6ced3f54a1d /src/ipcpd | |
parent | 7c5727c35c961c0b579a754ecdf0870b8db383b1 (diff) | |
download | ouroboros-6a119fb353ec862151543489201b20f67628a6f2.tar.gz ouroboros-6a119fb353ec862151543489201b20f67628a6f2.zip |
ipcpd: normal: Fix negative malloc
This adds a check to prevent a negative malloc in case the graph
structure is empty.
Diffstat (limited to 'src/ipcpd')
-rw-r--r-- | src/ipcpd/normal/graph.c | 11 |
1 files changed, 11 insertions, 0 deletions
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); |