Module: kamailio Branch: master Commit: 2cc62133db4f6875f55e73e044f37dafbb2274c2 URL: https://github.com/kamailio/kamailio/commit/2cc62133db4f6875f55e73e044f37daf...
Author: Daniel-Constantin Mierla miconda@gmail.com Committer: Daniel-Constantin Mierla miconda@gmail.com Date: 2024-04-23T12:08:30+02:00
regex: allocate pcres array
- GH #3812
---
Modified: src/modules/regex/regex_mod.c
---
Diff: https://github.com/kamailio/kamailio/commit/2cc62133db4f6875f55e73e044f37daf... Patch: https://github.com/kamailio/kamailio/commit/2cc62133db4f6875f55e73e044f37daf...
---
diff --git a/src/modules/regex/regex_mod.c b/src/modules/regex/regex_mod.c index 8e8c1645f0e..4bb4d7cdcee 100644 --- a/src/modules/regex/regex_mod.c +++ b/src/modules/regex/regex_mod.c @@ -462,6 +462,15 @@ 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_addr = pcres;