conf: handle regcomp errors and warn

Instead of silently ignoring the problem.

See #3460
This commit is contained in:
Wim Taymans 2023-08-25 11:08:18 +02:00
parent c41c812325
commit 0bfc02581f

View file

@ -619,7 +619,12 @@ static bool find_match(struct spa_json *arr, const struct spa_dict *props)
if (str != NULL) { if (str != NULL) {
if (value[0] == '~') { if (value[0] == '~') {
regex_t preg; regex_t preg;
if (regcomp(&preg, value+1, REG_EXTENDED | REG_NOSUB) == 0) { int res;
if ((res = regcomp(&preg, value+1, REG_EXTENDED | REG_NOSUB)) != 0) {
char errbuf[1024];
regerror(res, &preg, errbuf, sizeof(errbuf));
pw_log_warn("invalid regex %s: %s", value+1, errbuf);
} else {
if (regexec(&preg, str, 0, NULL, 0) == 0) if (regexec(&preg, str, 0, NULL, 0) == 0)
success = true; success = true;
regfree(&preg); regfree(&preg);