Skip to content

Commit

Permalink
ldap: convert to memory error logging helper
Browse files Browse the repository at this point in the history
  • Loading branch information
pantelisk98 authored and henningw committed Apr 29, 2023
1 parent b1a4774 commit ea31785
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
8 changes: 4 additions & 4 deletions src/modules/ldap/ld_session.c
Expand Up @@ -43,7 +43,7 @@ int add_ld_session(char *_name, LDAP *_ldh, dictionary *_d)

new_lds = (struct ld_session *)pkg_malloc(sizeof(struct ld_session));
if(new_lds == NULL) {
LM_ERR("no memory\n");
PKG_MEM_ERROR;
return -1;
}
memset(new_lds, 0, sizeof(struct ld_session));
Expand All @@ -58,7 +58,7 @@ int add_ld_session(char *_name, LDAP *_ldh, dictionary *_d)
_d, get_ini_key_name(_name, CFG_N_LDAP_HOST), CFG_DEF_HOST_NAME);
new_lds->host_name = (char *)pkg_malloc(strlen(host_name) + 1);
if(new_lds->host_name == NULL) {
LM_ERR("no memory\n");
PKG_MEM_ERROR;
pkg_free(new_lds);
return -1;
}
Expand Down Expand Up @@ -104,7 +104,7 @@ int add_ld_session(char *_name, LDAP *_ldh, dictionary *_d)
get_ini_key_name(_name, CFG_N_LDAP_BIND_DN), CFG_DEF_LDAP_BIND_DN);
new_lds->bind_dn = (char *)pkg_malloc(strlen(bind_dn) + 1);
if(new_lds->bind_dn == NULL) {
LM_ERR("no memory\n");
PKG_MEM_ERROR;
pkg_free(new_lds->host_name);
pkg_free(new_lds);
return -1;
Expand All @@ -117,7 +117,7 @@ int add_ld_session(char *_name, LDAP *_ldh, dictionary *_d)
CFG_DEF_LDAP_BIND_PWD);
new_lds->bind_pwd = (char *)pkg_malloc(strlen(bind_pwd) + 1);
if(new_lds->bind_pwd == NULL) {
LM_ERR("no memory\n");
PKG_MEM_ERROR;
pkg_free(new_lds->bind_dn);
pkg_free(new_lds->host_name);
pkg_free(new_lds);
Expand Down
6 changes: 3 additions & 3 deletions src/modules/ldap/ldap_mod.c
Expand Up @@ -328,7 +328,7 @@ static int ldap_result_fixup(void **param, int param_no)
lp = (struct ldap_result_params *)pkg_malloc(
sizeof(struct ldap_result_params));
if(lp == NULL) {
LM_ERR("no memory\n");
PKG_MEM_ERROR;
return E_OUT_OF_MEM;
}
memset(lp, 0, sizeof(struct ldap_result_params));
Expand Down Expand Up @@ -388,7 +388,7 @@ static int ldap_result_check_fixup(void **param, int param_no)
lp = (struct ldap_result_check_params *)pkg_malloc(
sizeof(struct ldap_result_check_params));
if(lp == NULL) {
LM_ERR("no memory\n");
PKG_MEM_ERROR;
return E_OUT_OF_MEM;
}
memset(lp, 0, sizeof(struct ldap_result_check_params));
Expand Down Expand Up @@ -444,7 +444,7 @@ static int ldap_filter_url_encode_fixup(void **param, int param_no)
} else if(param_no == 2) {
spec_p = (pv_spec_t *)pkg_malloc(sizeof(pv_spec_t));
if(spec_p == NULL) {
LM_ERR("no memory\n");
PKG_MEM_ERROR;
return E_OUT_OF_MEM;
}
s.s = (char *)*param;
Expand Down

0 comments on commit ea31785

Please sign in to comment.