From de48be80ae5a6380434913bd177e17c7d8cb42c5 Mon Sep 17 00:00:00 2001 From: Henning Westerholt Date: Tue, 25 Dec 2018 23:41:57 +0100 Subject: [PATCH] core: fix a resource leak in the case for memory allocation error --- src/core/socket_info.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/core/socket_info.c b/src/core/socket_info.c index 16704a6f29b..0ba1be5fe39 100644 --- a/src/core/socket_info.c +++ b/src/core/socket_info.c @@ -215,7 +215,8 @@ static int new_addr_info2list(char* name, enum si_flags f, -/* another helper function, it just creates a socket_info struct */ +/* another helper function, it just creates a socket_info struct + * allocates a si and a si->name in new pkg memory */ static inline struct socket_info* new_sock_info( char* name, struct name_lst* addr_l, unsigned short port, unsigned short proto, @@ -702,7 +703,7 @@ static struct socket_info* new_sock2list(char* name, struct name_lst* addr_l, struct socket_info** list) { struct socket_info* si; - + /* allocates si and si->name in new pkg memory */ si=new_sock_info(name, addr_l, port, proto, usename, useport, flags); if (si==0){ LM_ERR("new_sock_info failed\n"); @@ -718,6 +719,8 @@ static struct socket_info* new_sock2list(char* name, struct name_lst* addr_l, si->mcast.s=(char*)pkg_malloc(si->mcast.len+1); if (si->mcast.s==0) { PKG_MEM_ERROR; + pkg_free(si->name.s); + pkg_free(si); return 0; } strcpy(si->mcast.s, mcast);