diff options
author | Dimitri Staessens <dimitri@ouroboros.rocks> | 2020-05-29 16:52:14 +0200 |
---|---|---|
committer | Sander Vrijders <sander@ouroboros.rocks> | 2020-05-29 17:06:39 +0200 |
commit | bd6cce48b929468f6afc5294de19b688494c3a71 (patch) | |
tree | 3d3e1addcb4b7c4fb8cffd59f1fdf4f2a092a946 /src/ipcpd/unicast/dht.c | |
parent | 5c12e2efc066f09c0e7ed21ed0bb3a3ce635cb0a (diff) | |
download | ouroboros-bd6cce48b929468f6afc5294de19b688494c3a71.tar.gz ouroboros-bd6cce48b929468f6afc5294de19b688494c3a71.zip |
ipcpd: Fix leak and unitialized variable in DHT
There were some issues identified by the Clang static analyzer that
are now fixed.
Signed-off-by: Dimitri Staessens <dimitri@ouroboros.rocks>
Signed-off-by: Sander Vrijders <sander@ouroboros.rocks>
Diffstat (limited to 'src/ipcpd/unicast/dht.c')
-rw-r--r-- | src/ipcpd/unicast/dht.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/ipcpd/unicast/dht.c b/src/ipcpd/unicast/dht.c index 8555312e..8a78bfca 100644 --- a/src/ipcpd/unicast/dht.c +++ b/src/ipcpd/unicast/dht.c @@ -1946,6 +1946,7 @@ static ssize_t dht_get_contacts(struct dht * dht, len = dht_contact_list(dht, &l, key); if (len == 0) { pthread_rwlock_unlock(&dht->lock); + *msgs = NULL; return 0; } @@ -1963,6 +1964,7 @@ static ssize_t dht_get_contacts(struct dht * dht, while (i > 0) free(*msgs[--i]); free(*msgs); + *msgs = NULL; return 0; } @@ -2552,7 +2554,7 @@ static void * dht_handle_packet(void * o) if (dht_get_state(dht) == DHT_JOINING && dht->buckets == NULL) { pthread_rwlock_unlock(&dht->lock); - break; + goto finish; } if (dht_update_bucket(dht, msg->s_id.data, addr)) @@ -2563,6 +2565,7 @@ static void * dht_handle_packet(void * o) if (msg->code < KAD_STORE && send_msg(dht, &resp_msg, addr) < 0) log_warn("Failed to send response."); + finish: kad_msg__free_unpacked(msg, NULL); if (resp_msg.n_addrs > 0) |