Module: kamailio
Branch: master
Commit: 40b18ddfe3eca3170ef6c535d39332b2e3c6ce5d
URL:
https://github.com/kamailio/kamailio/commit/40b18ddfe3eca3170ef6c535d39332b…
Author: Pantelis Kolatsis <pk(a)gilawa.com>
Committer: Henning Westerholt <hw(a)gilawa.com>
Date: 2023-05-04T08:06:37Z
secfilter: convert to memory error logging helper, add missing mem cleanup on errors
---
Modified: src/modules/secfilter/secfilter.c
---
Diff:
https://github.com/kamailio/kamailio/commit/40b18ddfe3eca3170ef6c535d39332b…
Patch:
https://github.com/kamailio/kamailio/commit/40b18ddfe3eca3170ef6c535d39332b…
---
diff --git a/src/modules/secfilter/secfilter.c b/src/modules/secfilter/secfilter.c
index 5e967b2204b..061a1eb7445 100644
--- a/src/modules/secfilter/secfilter.c
+++ b/src/modules/secfilter/secfilter.c
@@ -276,7 +276,7 @@ static int w_check_sqli(str val)
cval = (char *)pkg_malloc(val.len + 1);
if(cval == NULL) {
- LM_CRIT("Cannot allocate pkg memory\n");
+ PKG_MEM_CRITICAL;
return -2;
}
memset(cval, 0, val.len + 1);
@@ -752,6 +752,7 @@ int secf_init_data(void)
secf_data_2 = (secf_data_p)shm_malloc(sizeof(secf_data_t));
if(!secf_data_2) {
SHM_MEM_ERROR;
+ shm_free(secf_data_1);
return -1;
}
memset(secf_data_2, 0, sizeof(secf_data_t));
@@ -759,10 +760,20 @@ int secf_init_data(void)
secf_data = shm_malloc(sizeof(secf_data_t));
if(secf_data == NULL) {
SHM_MEM_ERROR;
+ shm_free(secf_data_1);
+ shm_free(secf_data_2);
return -1;
}
secf_stats = shm_malloc(total_data * sizeof(int));
+ if(!secf_stats)
+ {
+ SHM_MEM_ERROR;
+ shm_free(secf_data_1);
+ shm_free(secf_data_2);
+ shm_free(secf_data);
+ return -1;
+ }
memset(secf_stats, 0, total_data * sizeof(int));
if(secf_dst_exact_match != 0)