Module: kamailio
Branch: master
Commit: 6d3a97d1c3e62f876bbb7a17927b2a40243ec268
URL:
https://github.com/kamailio/kamailio/commit/6d3a97d1c3e62f876bbb7a17927b2a4…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2017-07-27T13:08:19+02:00
ldap: free in case of error cases
---
Modified: src/modules/ldap/ld_session.c
Modified: src/modules/ldap/ldap_mod.c
---
Diff:
https://github.com/kamailio/kamailio/commit/6d3a97d1c3e62f876bbb7a17927b2a4…
Patch:
https://github.com/kamailio/kamailio/commit/6d3a97d1c3e62f876bbb7a17927b2a4…
---
diff --git a/src/modules/ldap/ld_session.c b/src/modules/ldap/ld_session.c
index 25ad429c42..8a27d08004 100644
--- a/src/modules/ldap/ld_session.c
+++ b/src/modules/ldap/ld_session.c
@@ -62,6 +62,7 @@ int add_ld_session(char* _name, LDAP* _ldh, dictionary* _d)
new_lds->host_name = (char*)pkg_malloc(strlen(host_name)+1);
if (new_lds->host_name == NULL) {
LM_ERR("no memory\n");
+ pkg_free(new_lds);
return -1;
}
strcpy(new_lds->host_name, host_name);
@@ -117,6 +118,8 @@ int add_ld_session(char* _name, LDAP* _ldh, dictionary* _d)
new_lds->bind_dn = (char*)pkg_malloc(strlen(bind_dn)+1);
if (new_lds->bind_dn == NULL) {
LM_ERR("no memory\n");
+ pkg_free(new_lds->host_name);
+ pkg_free(new_lds);
return -1;
}
strcpy(new_lds->bind_dn, bind_dn);
@@ -129,6 +132,9 @@ int add_ld_session(char* _name, LDAP* _ldh, dictionary* _d)
new_lds->bind_pwd = (char*)pkg_malloc(strlen(bind_pwd)+1);
if (new_lds->bind_pwd == NULL) {
LM_ERR("no memory\n");
+ pkg_free(new_lds->bind_dn);
+ pkg_free(new_lds->host_name);
+ pkg_free(new_lds);
return -1;
}
strcpy(new_lds->bind_pwd, bind_pwd);
diff --git a/src/modules/ldap/ldap_mod.c b/src/modules/ldap/ldap_mod.c
index 89eb89cb99..59367a83c8 100644
--- a/src/modules/ldap/ldap_mod.c
+++ b/src/modules/ldap/ldap_mod.c
@@ -447,6 +447,7 @@ static int ldap_result_check_fixup(void** param, int param_no)
if (pv_parse_format(&s, &(lp->check_str_elem_p)) < 0)
{
LM_ERR("pv_parse_format failed\n");
+ pkg_free(lp);
return E_OUT_OF_MEM;
}
}