From 302ad5025fd2d0b4305002a7301769eeaf8838b5 Mon Sep 17 00:00:00 2001 From: Sean Hunt Date: Fri, 3 Apr 2015 16:25:17 -0400 Subject: [PATCH] Catch regex matching errors to avoid crashing. --- sys/share/cppregex.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/sys/share/cppregex.cpp b/sys/share/cppregex.cpp index 8d0704fde..e775d7c6f 100644 --- a/sys/share/cppregex.cpp +++ b/sys/share/cppregex.cpp @@ -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) {