Browse Source

regex: allocate pcres array

- GH #3812
Daniel-Constantin Mierla 1 năm trước cách đây
mục cha
commit
2cc62133db
1 tập tin đã thay đổi với 9 bổ sung0 xóa
  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;