
Is a malformed regex supposed to crash the library? See enclosed .cpp file kernel32.dll!7c81eb33() [Frames below may be incorrect and/or missing, no symbols loaded for kernel32.dll] kernel32.dll!7c81eb33() msvcp80d.dll!1048902d() msvcp80d.dll!1048843a() msvcr80d.dll!10243990() example.exe!boost::throw_exception<boost::regex_error>(const boost::regex_error & e={...}) Line 40 C++ example.exe!boost::regex_error::raise() Line 74 + 0x9 bytes C++ example.exe!boost::re_detail::basic_regex_parser<char,boost::regex_traits<char,boost::w32_regex_traits<char> > >::fail(boost::regex_constants::error_type error_code=error_paren, int position=20) Line 161 C++ example.exe!boost::re_detail::basic_regex_parser<char,boost::regex_traits<char,boost::w32_regex_traits<char> > >::parse_open_paren() Line 398 C++ example.exe!boost::re_detail::basic_regex_parser<char,boost::regex_traits<char,boost::w32_regex_traits<char> > >::parse_extended() Line 238 + 0x8 bytes C++ example.exe!boost::re_detail::basic_regex_parser<char,boost::regex_traits<char,boost::w32_regex_traits<char> > >::parse_all() Line 173 + 0xb bytes C++ example.exe!boost::re_detail::basic_regex_parser<char,boost::regex_traits<char,boost::w32_regex_traits<char> > >::parse(const char * p1=0x0048981c, const char * p2=0x00489830, unsigned int flags=0) Line 125 + 0x8 bytes C++
example.exe!boost::re_detail::basic_regex_implementation<char,boost::regex_traits<char,boost::w32_regex_traits<char> > >::assign(const char * arg_first=0x0048981c, const char * arg_last=0x00489830, unsigned int f=0) Line 96 C++ example.exe!boost::basic_regex<char,boost::regex_traits<char,boost::w32_regex_traits<char> > >::do_assign(const char * p1=0x0048981c, const char * p2=0x00489830, unsigned int f=0) Line 524 C++ example.exe!boost::basic_regex<char,boost::regex_traits<char,boost::w32_regex_traits<char> > >::assign(const char * p1=0x0048981c, const char * p2=0x00489830, unsigned int f=0) Line 255 C++ example.exe!boost::basic_regex<char,boost::regex_traits<char,boost::w32_regex_traits<char> > >::assign(const char * p=0x0048981c, unsigned int f=0) Line 240 C++ example.exe!boost::basic_regex<char,boost::regex_traits<char,boost::w32_regex_traits<char> > >::basic_regex<char,boost::regex_traits<char,boost::w32_regex_traits<char> > >(const char * p=0x0048981c, unsigned int f=0) Line 209 C++ example.exe!main() Line 8 + 0xf bytes C++ example.exe!__tmainCRTStartup() Line 586 + 0x19 bytes C example.exe!mainCRTStartup() Line 403 C kernel32.dll!7c816d4f() kernel32.dll!7c8399f3()
#include <boost/regex.hpp> #include <iostream> #include <string> int main() { std::string line; boost::regex pat("^Subject: (Re: )?(.*"); boost::smatch matches; while (std::cin) { std::getline(std::cin, line); if (boost::regex_match(line, matches, pat)) std::cout << matches[2]; } } -- Dave Abrahams Boost Consulting www.boost-consulting.com

David Abrahams <dave@boost-consulting.com> writes:
Is a malformed regex supposed to crash the library? See enclosed .cpp file
Sorry, I'm a fool; this was an exception from the library, but the debugger showed me some line in the middle of the backtrace, so I couldn't see it. -- Dave Abrahams Boost Consulting www.boost-consulting.com

On 2/7/06, David Abrahams <dave@boost-consulting.com> wrote:
Is a malformed regex supposed to crash the library? See enclosed .cpp file
It seems to me that it doesnt crash the library But throws an exception that's not caught [snip - stack trace and example] With this: #include <boost/regex.hpp> #include <iostream> #include <string> int main() { try { std::string line; boost::regex pat("^Subject: (Re: )?(.*"); boost::smatch matches; while (std::cin) { std::getline(std::cin, line); if (boost::regex_match(line, matches, pat)) std::cout << matches[2]; } } catch(std::exception&e) { std::cerr << e.what() << std::endl; } } gives me this output: Unmatched ( or \(
-- Dave Abrahams Boost Consulting www.boost-consulting.com
best regards, -- Felipe Magno de Almeida
participants (2)
-
David Abrahams
-
Felipe Magno de Almeida