summaryrefslogtreecommitdiff
path: root/src/ipcpd/normal
diff options
context:
space:
mode:
authorDimitri Staessens <dimitri.staessens@ugent.be>2018-05-25 19:12:59 +0200
committerSander Vrijders <sander.vrijders@ugent.be>2018-05-27 15:26:06 +0200
commit3d58f8ed91fe470e8b496fac97b899739a752e90 (patch)
tree02f3d55823229fc7dc3a4769b573f8325209363b /src/ipcpd/normal
parent0a80c263488bbc7b9419f8cba14f3adeedba0383 (diff)
downloadouroboros-3d58f8ed91fe470e8b496fac97b899739a752e90.tar.gz
ouroboros-3d58f8ed91fe470e8b496fac97b899739a752e90.zip
ipcpd: Fix memleak in DHT
This fixes a memleak for the info struct when join thread creation is not needed. Fixes a false positive warning when running the clang static analyzer. Removes a use-after-free warning that is not valid since 0.11.4. Signed-off-by: Dimitri Staessens <dimitri.staessens@ugent.be> Signed-off-by: Sander Vrijders <sander.vrijders@ugent.be>
Diffstat (limited to 'src/ipcpd/normal')
-rw-r--r--src/ipcpd/normal/dht.c14
1 files changed, 5 insertions, 9 deletions
diff --git a/src/ipcpd/normal/dht.c b/src/ipcpd/normal/dht.c
index b8bd03fa..917cbc15 100644
--- a/src/ipcpd/normal/dht.c
+++ b/src/ipcpd/normal/dht.c
@@ -825,12 +825,6 @@ static void lookup_update(struct dht * dht,
pthread_cleanup_pop(false);
- /* BUG: this should not be allowed since it's use-after-free. */
- if (lu->state == LU_DESTROY || lu->state == LU_NULL) {
- log_warn("Use-after-free. Update aborted to avoid worse.");
- return;
- }
-
for (n = 0; n < msg->n_contacts; ++n) {
c = contact_create(msg->contacts[n]->id.data,
dht->b, msg->contacts[n]->addr);
@@ -1905,11 +1899,11 @@ static buffer_t dht_retrieve(struct dht * dht,
if (buf.len == 0)
goto fail;
- buf.data = malloc(sizeof(dht->addr) * buf.len);
- if (buf.data == NULL)
+ pos = malloc(sizeof(dht->addr) * buf.len);
+ if (pos == NULL)
goto fail;
- pos = (uint64_t *) buf.data;;
+ buf.data = (uint8_t *) pos;
list_for_each(p, &e->vals) {
struct val * v = list_entry(p, struct val, next);
@@ -2747,6 +2741,8 @@ static void handle_event(void * self,
return;
}
pthread_detach(thr);
+ } else {
+ free(inf);
}
break;
case DHT_RUNNING: