diff options
author | Sander Vrijders <sander.vrijders@intec.ugent.be> | 2016-03-17 15:20:29 +0100 |
---|---|---|
committer | Sander Vrijders <sander.vrijders@intec.ugent.be> | 2016-03-17 15:20:29 +0100 |
commit | 02681c391cbc1cc08f2dea5d8499f301d9321147 (patch) | |
tree | 54bc0a9cfb51c1759bb2056961c555fcc9979da7 /src/lib/ipcp.c | |
parent | 722b769e4d519f2428ee893a78cafa999151bb1c (diff) | |
download | ouroboros-02681c391cbc1cc08f2dea5d8499f301d9321147.tar.gz ouroboros-02681c391cbc1cc08f2dea5d8499f301d9321147.zip |
lib: Clean up memleaks
Some allocations were not freed in case the creation of a new IPCP
failed.
Diffstat (limited to 'src/lib/ipcp.c')
-rw-r--r-- | src/lib/ipcp.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/lib/ipcp.c b/src/lib/ipcp.c index 7870e478..6bc3c75f 100644 --- a/src/lib/ipcp.c +++ b/src/lib/ipcp.c @@ -104,14 +104,15 @@ pid_t ipcp_create(rina_name_t name, api_id = malloc(n_digits(name.api_id) + 1); if (!api_id) { LOG_ERR("Failed to malloc"); - exit(-1); + exit(EXIT_FAILURE); } sprintf(api_id, "%d", name.api_id); aei_id = malloc(n_digits(name.aei_id) + 1); if (!aei_id) { LOG_ERR("Failed to malloc"); - exit(-1); + free(api_id); + exit(EXIT_FAILURE); } sprintf(aei_id, "%d", name.aei_id); @@ -121,7 +122,9 @@ pid_t ipcp_create(rina_name_t name, full_name = malloc(len); if (!full_name) { LOG_ERR("Failed to malloc"); - exit(-1); + free(api_id); + free(aei_id); + exit(EXIT_FAILURE); } strcpy(full_name, INSTALL_DIR); @@ -140,7 +143,10 @@ pid_t ipcp_create(rina_name_t name, LOG_DBG("%s", strerror(errno)); LOG_ERR("Failed to load IPCP daemon"); LOG_ERR("Make sure to run the installed version"); - exit(-1); + free(api_id); + free(aei_id); + free(full_name); + exit(EXIT_FAILURE); } int ipcp_destroy(pid_t pid) |