Change POSIX API's so regcomp doesn't check for magic value and read potentially uninitialized memory.

See https://svn.boost.org/trac/boost/ticket/11472.
This commit is contained in:
jzmaddock
2015-09-25 12:41:02 +01:00
parent 94c7d4a38a
commit d8c95a9950
2 changed files with 18 additions and 24 deletions

View File

@ -68,23 +68,20 @@ typedef boost::basic_regex<char, c_regex_traits<char> > c_regex_type;
BOOST_REGEX_DECL int BOOST_REGEX_CCALL regcompA(regex_tA* expression, const char* ptr, int f)
{
if(expression->re_magic != magic_value)
{
expression->guts = 0;
#ifndef BOOST_NO_EXCEPTIONS
try{
try{
#endif
expression->guts = new c_regex_type();
#ifndef BOOST_NO_EXCEPTIONS
} catch(...)
{
return REG_ESPACE;
}
#else
if(0 == expression->guts)
return REG_E_MEMORY;
#endif
} catch(...)
{
expression->guts = 0;
return REG_ESPACE;
}
#else
if(0 == expression->guts)
return REG_E_MEMORY;
#endif
// set default flags:
boost::uint_fast32_t flags = (f & REG_PERLEX) ? 0 : ((f & REG_EXTENDED) ? regex::extended : regex::basic);
expression->eflags = (f & REG_NEWLINE) ? match_not_dot_newline : match_default;