summaryrefslogtreecommitdiff
path: root/src/ipcpd/shim-udp
diff options
context:
space:
mode:
authorSander Vrijders <sander.vrijders@intec.ugent.be>2017-02-04 09:12:47 +0000
committerSander Vrijders <sander.vrijders@intec.ugent.be>2017-02-04 09:12:47 +0000
commite3b1288354349edc53c7c3c9ebd3efe23a7df10d (patch)
tree3a47f2b2db895173a1e3605df3fbdc925b7b127b /src/ipcpd/shim-udp
parentc677d8a88065e6bc8e071f3f03a440e4ed083abb (diff)
parenta30e244407655d16429ef442ac23db43a548bf95 (diff)
downloadouroboros-e3b1288354349edc53c7c3c9ebd3efe23a7df10d.tar.gz
ouroboros-e3b1288354349edc53c7c3c9ebd3efe23a7df10d.zip
Merged in dstaesse/ouroboros/be-wip (pull request #359)
irmd: Fix memleak in registry
Diffstat (limited to 'src/ipcpd/shim-udp')
-rw-r--r--src/ipcpd/shim-udp/main.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/ipcpd/shim-udp/main.c b/src/ipcpd/shim-udp/main.c
index e9c15579..c2f86067 100644
--- a/src/ipcpd/shim-udp/main.c
+++ b/src/ipcpd/shim-udp/main.c
@@ -776,17 +776,25 @@ static int ipcp_udp_name_reg(char * name)
uint32_t dns_addr;
uint32_t ip_addr;
#endif
+ char * name_dup;
if (strlen(name) > 24) {
LOG_ERR("DNS names cannot be longer than 24 chars.");
return -1;
}
+ name_dup = strdup(name);
+ if (name_dup == NULL) {
+ LOG_ERR("Failed to duplicate name.");
+ return -ENOMEM;
+ }
+
pthread_rwlock_rdlock(&ipcpi.state_lock);
- if (ipcp_data_reg_add_entry(ipcpi.data, name)) {
+ if (ipcp_data_reg_add_entry(ipcpi.data, name_dup)) {
pthread_rwlock_unlock(&ipcpi.state_lock);
LOG_ERR("Failed to add %s to local registry.", name);
+ free(name_dup);
return -1;
}