소스 검색

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;