@@ -1151,19 +1151,19 @@ bool regex_exec(
11511151
11521152void regerror (char const * s) { out_printf (" re error %s\n " , s); }
11531153
1154- regex_prog & program::compile (const char * pattern)
1154+ regex_prog * program::compile (const char * pattern)
11551155{
11561156 static std::unordered_map<std::string, regex_prog_ptr> cache;
11571157 if (cache.count (pattern) == 0 )
11581158 {
11591159 cache[pattern] = regex_comp (pattern);
11601160 }
1161- return * cache[pattern];
1161+ return cache[pattern]. get () ;
11621162}
11631163
11641164program::program (const char * pattern) { reset (pattern); }
11651165
1166- void program::reset (const char * pattern) { compiled = & compile (pattern); }
1166+ void program::reset (const char * pattern) { compiled = compile (pattern); }
11671167
11681168program::result_iterator::result_iterator (
11691169 const regex_prog & c, const string_view & s)
@@ -1176,7 +1176,7 @@ program::result_iterator::result_iterator(
11761176void program::result_iterator::advance ()
11771177{
11781178 // We start searching for a match at the end of the previous match.
1179- if (regex_exec (*compiled, expressions, rest))
1179+ if ((compiled != nullptr ) && regex_exec (*compiled, expressions, rest))
11801180 {
11811181 // A match means the subexpressions are filled in and the first entry
11821182 // is the full match. Advance `rest` to follow the match.
0 commit comments