From 4de841c26b7208d5395da349ea16c937b1361414 Mon Sep 17 00:00:00 2001 From: Sander Vrijders Date: Tue, 29 Aug 2017 13:14:25 +0200 Subject: lib, ipcpd, irmd: Fix bugs reported by static analysis This fixes several bugs as reported by the clang static analyzer. --- src/ipcpd/normal/dht.c | 3 ++- src/ipcpd/normal/pol/graph.c | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) (limited to 'src/ipcpd/normal') diff --git a/src/ipcpd/normal/dht.c b/src/ipcpd/normal/dht.c index b5d52d93..b5bac913 100644 --- a/src/ipcpd/normal/dht.c +++ b/src/ipcpd/normal/dht.c @@ -745,7 +745,8 @@ static void lookup_update(struct dht * dht, } else { struct contact * d; list_add_tail(&c->next, p); - d = list_last_entry(&lu->contacts, struct contact, next); + d = list_last_entry(&lu->contacts, + struct contact, next); list_del(&d->next); contact_destroy(d); } diff --git a/src/ipcpd/normal/pol/graph.c b/src/ipcpd/normal/pol/graph.c index 3611f0b0..9901fbaa 100644 --- a/src/ipcpd/normal/pol/graph.c +++ b/src/ipcpd/normal/pol/graph.c @@ -454,9 +454,10 @@ ssize_t graph_routing_table(struct graph * graph, pthread_mutex_lock(&graph->lock); - if (graph->nr_vertices == 0) { + /* We need at least 2 vertices for a table */ + if (graph->nr_vertices < 2) { pthread_mutex_unlock(&graph->lock); - return 0; + return -1; } prevs = dijkstra(graph, s_addr); -- cgit v1.2.3