Module: kamailio
Branch: master
Commit: d89333748662c0e7c72e3579d41fd14ef05c0fee
URL: 
https://github.com/kamailio/kamailio/commit/d89333748662c0e7c72e3579d41fd14ef05c0fee

Author: Victor Seva <linuxman...@torreviejawireless.org>
Committer: Victor Seva <linuxman...@torreviejawireless.org>
Date: 2024-05-30T16:36:30+02:00

regex: fix pcre2 migration

instead of reserving an array in pkg_mem and later
copy the pointers to shm_mem just use shm_mem in
the first place.

fixes #3812

---

Modified: src/modules/regex/regex_mod.c

---

Diff:  
https://github.com/kamailio/kamailio/commit/d89333748662c0e7c72e3579d41fd14ef05c0fee.diff
Patch: 
https://github.com/kamailio/kamailio/commit/d89333748662c0e7c72e3579d41fd14ef05c0fee.patch

---

diff --git a/src/modules/regex/regex_mod.c b/src/modules/regex/regex_mod.c
index 292af692136..52ed60b295c 100644
--- a/src/modules/regex/regex_mod.c
+++ b/src/modules/regex/regex_mod.c
@@ -427,7 +427,7 @@ static int load_pcres(int action)
        }
 
        /* Temporal pointer of pcres */
-       if((pcres_tmp = pkg_malloc(sizeof(pcre2_code *) * num_pcres_tmp)) == 0) 
{
+       if((pcres_tmp = shm_malloc(sizeof(pcre2_code *) * num_pcres_tmp)) == 0) 
{
                LM_ERR("no more memory for pcres_tmp\n");
                goto err;
        }
@@ -469,19 +469,10 @@ static int load_pcres(int action)
                shm_free(pcres);
        }
 
-       if(pcres == NULL) {
-               if((pcres = shm_malloc(sizeof(pcre2_code *) * num_pcres_tmp)) 
== 0) {
-                       LM_ERR("no more memory for pcres\n");
-                       goto err;
-               }
-               memset(pcres, 0, sizeof(pcre2_code *) * num_pcres_tmp);
-       }
-
        *num_pcres = num_pcres_tmp;
-       *pcres = *pcres_tmp;
+       pcres = pcres_tmp;
        *pcres_addr = pcres;
 
-       pkg_free(pcres_tmp);
        /* Free allocated slots for unused patterns */
        for(i = num_pcres_tmp; i < max_groups; i++) {
                pkg_free(patterns[i]);

_______________________________________________
Kamailio (SER) - Development Mailing List
To unsubscribe send an email to sr-dev-le...@lists.kamailio.org

Reply via email to