From 2cc62133db4f6875f55e73e044f37dafbb2274c2 Mon Sep 17 00:00:00 2001 From: Daniel-Constantin Mierla Date: Tue, 23 Apr 2024 12:08:30 +0200 Subject: [PATCH] regex: allocate pcres array - GH #3812 --- src/modules/regex/regex_mod.c | 9 +++++++++ 1 file changed, 9 insertions(+) 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;