Catch regex matching errors to avoid crashing.

This commit is contained in:
Sean Hunt
2015-04-03 16:25:17 -04:00
parent 80aa109855
commit 302ad5025f

View File

@@ -42,7 +42,11 @@ extern "C" {
boolean regex_match(const char *s, struct nhregex *re) {
if (!re->re)
return false;
return regex_search(s, *re->re, std::regex_constants::match_any);
try {
return regex_search(s, *re->re, std::regex_constants::match_any);
} catch (const std::regex_error& err) {
return false;
}
}
void regex_free(struct nhregex *re) {