Skip to content

Commit

Permalink
ldap: free in case of error cases
Browse files Browse the repository at this point in the history
(cherry picked from commit 6d3a97d)
  • Loading branch information
miconda committed Aug 30, 2017
1 parent fa2ff3a commit 9095551
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/modules/ldap/ld_session.c
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand Down
1 change: 1 addition & 0 deletions src/modules/ldap/ldap_mod.c
Expand Up @@ -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;
}
}
Expand Down

0 comments on commit 9095551

Please sign in to comment.