summaryrefslogtreecommitdiff
path: root/src/irmd
diff options
context:
space:
mode:
authordimitri staessens <dimitri.staessens@intec.ugent.be>2017-01-29 17:20:09 +0100
committerdimitri staessens <dimitri.staessens@intec.ugent.be>2017-01-29 17:20:09 +0100
commit45a8dd4ccb3874c411dac287cf7ce862f051aa14 (patch)
tree608fa2506c847f7ebe1fb702333a74ecc2792bf5 /src/irmd
parentd6321a22f8c957523e7acbf6c57f5730b55ac378 (diff)
downloadouroboros-45a8dd4ccb3874c411dac287cf7ce862f051aa14.tar.gz
ouroboros-45a8dd4ccb3874c411dac287cf7ce862f051aa14.zip
irmd: Fix memleak attempting double bootstrap
When trying to double bootstrap, the entry name was strdup'd before the bootstrap leaking the previous name. Now it bootstraps first and sets the name after a successful bootstrap only.
Diffstat (limited to 'src/irmd')
-rw-r--r--src/irmd/main.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/src/irmd/main.c b/src/irmd/main.c
index 435ee116..02ffb21b 100644
--- a/src/irmd/main.c
+++ b/src/irmd/main.c
@@ -392,21 +392,19 @@ static int bootstrap_ipcp(pid_t api, dif_config_msg_t * conf)
return -1;
}
- entry->dif_name = strdup(conf->dif_name);
- if (entry->dif_name == NULL) {
+ if (ipcp_bootstrap(entry->api, conf)) {
pthread_rwlock_unlock(&irmd->reg_lock);
pthread_rwlock_unlock(&irmd->state_lock);
- LOG_ERR("Failed to strdup.");
+ LOG_ERR("Could not bootstrap IPCP.");
return -1;
}
- if (ipcp_bootstrap(entry->api, conf)) {
+ entry->dif_name = strdup(conf->dif_name);
+ if (entry->dif_name == NULL) {
pthread_rwlock_unlock(&irmd->reg_lock);
pthread_rwlock_unlock(&irmd->state_lock);
- LOG_ERR("Could not bootstrap IPCP.");
- free(entry->dif_name);
- entry->dif_name = NULL;
- return -1;
+ LOG_WARN("Failed to set name of DIF.");
+ return -ENOMEM;
}
pthread_rwlock_unlock(&irmd->reg_lock);