Catch regex matching errors to avoid crashing.

This commit is contained in:
Sean Hunt
2015-04-12 11:46:56 -04:00
parent 80aa109855
commit 302ad5025f
+5 -1
View File
@@ -42,7 +42,11 @@ extern "C" {
boolean regex_match(const char *s, struct nhregex *re) { boolean regex_match(const char *s, struct nhregex *re) {
if (!re->re) if (!re->re)
return false; 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) { void regex_free(struct nhregex *re) {