]> granicus.if.org Git - nethack/commitdiff
Catch regex matching errors to avoid crashing.
authorSean Hunt <scshunt@csclub.uwaterloo.ca>
Fri, 3 Apr 2015 20:25:17 +0000 (16:25 -0400)
committerSean Hunt <scshunt@csclub.uwaterloo.ca>
Sun, 12 Apr 2015 15:46:56 +0000 (11:46 -0400)
sys/share/cppregex.cpp

index 8d0704fde71dbbc8852f41113795cf58bc2cba5c..e775d7c6f18d3b190d1c1a337d0aaf72cf18c479 100644 (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) {