浏览代码

regex: allocate pcres array

- GH #3812
Daniel-Constantin Mierla 1 年之前
父节点
当前提交
2cc62133db
共有 1 个文件被更改,包括 9 次插入0 次删除
  1. 9 0
      src/modules/regex/regex_mod.c

+ 9 - 0
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;