From a30e244407655d16429ef442ac23db43a548bf95 Mon Sep 17 00:00:00 2001 From: dimitri staessens Date: Fri, 3 Feb 2017 20:38:39 +0100 Subject: ipcpd: Remove strdup() from ipcp main loop --- src/ipcpd/shim-eth-llc/main.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src/ipcpd/shim-eth-llc') diff --git a/src/ipcpd/shim-eth-llc/main.c b/src/ipcpd/shim-eth-llc/main.c index c59a8054..bc0d8a27 100644 --- a/src/ipcpd/shim-eth-llc/main.c +++ b/src/ipcpd/shim-eth-llc/main.c @@ -865,11 +865,18 @@ static int eth_llc_ipcp_bootstrap(struct dif_config * conf) static int eth_llc_ipcp_name_reg(char * name) { + char * 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; } -- cgit v1.2.3