diff options
author | Sander Vrijders <[email protected]> | 2017-08-29 13:14:25 +0200 |
---|---|---|
committer | Sander Vrijders <[email protected]> | 2017-08-29 13:14:25 +0200 |
commit | 4de841c26b7208d5395da349ea16c937b1361414 (patch) | |
tree | d86a1c02b36cfc5feea1ba5f22c6899f8a6c0c9c /src/irmd/main.c | |
parent | e8875c08ac04a1d9aca342d94d4f788239334f72 (diff) | |
download | ouroboros-4de841c26b7208d5395da349ea16c937b1361414.tar.gz ouroboros-4de841c26b7208d5395da349ea16c937b1361414.zip |
lib, ipcpd, irmd: Fix bugs reported by static analysis
This fixes several bugs as reported by the clang static analyzer.
Diffstat (limited to 'src/irmd/main.c')
-rw-r--r-- | src/irmd/main.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/irmd/main.c b/src/irmd/main.c index cc15e092..09a76214 100644 --- a/src/irmd/main.c +++ b/src/irmd/main.c @@ -307,6 +307,7 @@ static pid_t create_ipcp(char * name, entry = get_ipcp_entry_by_name(name); if (entry != NULL) { pthread_rwlock_unlock(&irmd.reg_lock); + free(api); log_err("IPCP by that name already exists."); return -1; } @@ -314,6 +315,7 @@ static pid_t create_ipcp(char * name, api->pid = ipcp_create(name, ipcp_type); if (api->pid == -1) { pthread_rwlock_unlock(&irmd.reg_lock); + free(api); log_err("Failed to create IPCP."); return -1; } @@ -321,6 +323,7 @@ static pid_t create_ipcp(char * name, tmp = ipcp_entry_create(); if (tmp == NULL) { pthread_rwlock_unlock(&irmd.reg_lock); + free(api); return -1; } @@ -330,6 +333,7 @@ static pid_t create_ipcp(char * name, if (tmp->name == NULL) { ipcp_entry_destroy(tmp); pthread_rwlock_unlock(&irmd.reg_lock); + free(api); return -1; } @@ -833,6 +837,11 @@ static ssize_t list_ipcps(char * name, count++; } + if (count == 0) { + pthread_rwlock_unlock(&irmd.reg_lock); + return 0; + } + *apis = malloc(count * sizeof(pid_t)); if (*apis == NULL) { pthread_rwlock_unlock(&irmd.reg_lock); @@ -1039,10 +1048,12 @@ static int api_announce(pid_t api, pthread_rwlock_unlock(&irmd.reg_lock); return -ENOMEM; } + n->str = strdup(s->str); if (n->str == NULL) { pthread_rwlock_unlock(&irmd.reg_lock); free(n); + return -ENOMEM; } list_add(&n->next, &e->names); |