Module: kamailio
Branch: master
Commit: fb1f01c333f9fc7189b6b3b6e39ddd28d30a5046
URL:
https://github.com/kamailio/kamailio/commit/fb1f01c333f9fc7189b6b3b6e39ddd2…
Author: Pantelis Kolatsis <pk(a)gilawa.com>
Committer: Henning Westerholt <hw(a)gilawa.com>
Date: 2023-03-29T09:44:07Z
pike: convert to memory logging helper, return error in case of allocation problem
---
Modified: src/modules/pike/ip_tree.c
Modified: src/modules/pike/pike.c
Modified: src/modules/pike/pike_top.c
---
Diff:
https://github.com/kamailio/kamailio/commit/fb1f01c333f9fc7189b6b3b6e39ddd2…
Patch:
https://github.com/kamailio/kamailio/commit/fb1f01c333f9fc7189b6b3b6e39ddd2…
---
diff --git a/src/modules/pike/ip_tree.c b/src/modules/pike/ip_tree.c
index a54351adefe..1f60f25e63e 100644
--- a/src/modules/pike/ip_tree.c
+++ b/src/modules/pike/ip_tree.c
@@ -114,7 +114,7 @@ int init_ip_tree(int maximum_hits)
/* create the pike_root */
pike_root = (pike_ip_tree_t*)shm_malloc(sizeof(pike_ip_tree_t));
if (pike_root==0) {
- LM_ERR("shm malloc failed\n");
+ SHM_MEM_ERROR;
goto error;
}
memset(pike_root, 0, sizeof(pike_ip_tree_t));
@@ -200,7 +200,7 @@ static inline pike_ip_node_t *new_ip_node(unsigned char byte)
new_node = (pike_ip_node_t*)shm_malloc(sizeof(pike_ip_node_t));
if (!new_node) {
- LM_ERR("no more shm mem\n");
+ SHM_MEM_ERROR;
return 0;
}
memset( new_node, 0, sizeof(pike_ip_node_t));
diff --git a/src/modules/pike/pike.c b/src/modules/pike/pike.c
index 33dcfd64204..89c79e95a85 100644
--- a/src/modules/pike/pike.c
+++ b/src/modules/pike/pike.c
@@ -126,7 +126,7 @@ static int pike_init(void)
/* init timer list */
pike_timer = (pike_list_link_t*)shm_malloc(sizeof(pike_list_link_t));
if (pike_timer==0) {
- LM_ERR("cannot alloc shm mem for timer!\n");
+ SHM_MEM_ERROR_FMT("for timer!\n");
goto error3;
}
pike_timer->next = pike_timer->prev = pike_timer;
diff --git a/src/modules/pike/pike_top.c b/src/modules/pike/pike_top.c
index e0bc3074620..6940e84ca67 100644
--- a/src/modules/pike/pike_top.c
+++ b/src/modules/pike/pike_top.c
@@ -80,7 +80,11 @@ int pike_top_add_entry( unsigned char *ip_addr, int addr_len,
{
struct TopListItem_t *new_item
= (struct TopListItem_t *)malloc(sizeof(struct TopListItem_t));
-
+ if(!new_item)
+ {
+ SYS_MEM_ERROR;
+ return -1;
+ }
print_addr(ip_addr, addr_len);
DBG("pike_top_add_enrty(ip: %s, leaf_hits[%d,%d], hits[%d,%d],"
" expires: %d, status: %d)",