Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2006-02-06 23:07:12


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

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk