Module: kamailio
Branch: master
Commit: 30f3bb9c0be0de638021ae4c7108db85330d3cbb
URL:
https://github.com/kamailio/kamailio/commit/30f3bb9c0be0de638021ae4c7108db8…
Author: Pantelis Kolatsis <pk(a)gilawa.com>
Committer: Henning Westerholt <hw(a)gilawa.com>
Date: 2023-04-21T17:40:27Z
xcap_server: convert to memory logging helper, improve mem error handling
---
Modified: src/modules/xcap_server/xcap_misc.c
Modified: src/modules/xcap_server/xcap_server.c
---
Diff:
https://github.com/kamailio/kamailio/commit/30f3bb9c0be0de638021ae4c7108db8…
Patch:
https://github.com/kamailio/kamailio/commit/30f3bb9c0be0de638021ae4c7108db8…
---
diff --git a/src/modules/xcap_server/xcap_misc.c b/src/modules/xcap_server/xcap_misc.c
index 0910b7d36e7..8c15ce17b93 100644
--- a/src/modules/xcap_server/xcap_misc.c
+++ b/src/modules/xcap_server/xcap_misc.c
@@ -589,7 +589,7 @@ int xcaps_xpath_set(str *inbuf, str *xpaths, str *val, str *outbuf)
outbuf->s = (char*)pkg_malloc(size+1);
if(outbuf->s==NULL)
{
- LM_ERR("no pkg for output\n");
+ PKG_MEM_ERROR_FMT("for output\n");
xmlFree(xmem);
goto error;
}
@@ -643,7 +643,7 @@ int xcaps_xpath_ns_param(modparam_t type, void *val)
if(ns==NULL)
{
- LM_ERR("no more pkg\n");
+ PKG_MEM_ERROR;
goto error;
}
memset(ns, 0, sizeof(param_t));
@@ -735,7 +735,7 @@ pv_xcap_uri_t *pv_xcap_uri_get_struct(str *name)
it = (pv_xcap_uri_t*)pkg_malloc(sizeof(pv_xcap_uri_t));
if(it==NULL)
{
- LM_ERR("no more pkg\n");
+ PKG_MEM_ERROR;
return NULL;
}
memset(it, 0, sizeof(pv_xcap_uri_t));
@@ -762,8 +762,10 @@ int pv_parse_xcap_uri_name(pv_spec_p sp, str *in)
pxs = (pv_xcap_uri_spec_t*)pkg_malloc(sizeof(pv_xcap_uri_spec_t));
if(pxs==NULL)
+ {
+ PKG_MEM_ERROR;
return -1;
-
+ }
memset(pxs, 0, sizeof(pv_xcap_uri_spec_t));
p = in->s;
diff --git a/src/modules/xcap_server/xcap_server.c
b/src/modules/xcap_server/xcap_server.c
index 20bb585e3a4..450634abbb9 100644
--- a/src/modules/xcap_server/xcap_server.c
+++ b/src/modules/xcap_server/xcap_server.c
@@ -171,7 +171,7 @@ static int mod_init(void)
xcaps_buf.s = (char*)pkg_malloc(xcaps_buf.len+1);
if(xcaps_buf.s==NULL)
{
- LM_ERR("no pkg\n");
+ PKG_MEM_ERROR;
return -1;
}
@@ -266,7 +266,7 @@ static int xcaps_send_reply(sip_msg_t *msg, int code, str *reason,
if (tbuf.len==0)
{
- LM_ERR("out of pkg memory\n");
+ PKG_MEM_ERROR;
return -1;
}
memcpy(tbuf.s, "Content-Type: ", sizeof("Content-Type: ") - 1);
@@ -545,7 +545,7 @@ static int ki_xcaps_put(sip_msg_t* msg, str* uri, str* path,
body.s = (char*)pkg_malloc(pbody->len+1);
if(body.s==NULL)
{
- LM_ERR("no more pkg\n");
+ PKG_MEM_ERROR;
goto error;
}
memcpy(body.s, pbody->s, pbody->len);
@@ -1033,6 +1033,11 @@ static int xcaps_get_directory(struct sip_msg *msg, str *user, str
*domain, str
else
{
server_name.s = pkg_malloc(IP6_MAX_STR_SIZE + 6);
+ if(!server_name.s)
+ {
+ PKG_MEM_ERROR;
+ goto error;
+ }
server_name.len = ip_addr2sbuf(&msg->rcv.dst_ip, server_name.s,
IP6_MAX_STR_SIZE);
directory->len += snprintf(directory->s + directory->len,
xcaps_buf.len - directory->len,
@@ -1172,7 +1177,7 @@ static int ki_xcaps_get(sip_msg_t* msg, str* uri, str* path)
{
if((new_body.s = pkg_malloc(body.len))==NULL)
{
- LM_ERR("allocating package memory\n");
+ PKG_MEM_ERROR;
goto error;
}
new_body.len = body.len;