de-fuzz, first fix for issue 14.

Make zeros in character set a single character long only.
This commit is contained in:
jzmaddock
2017-02-14 18:13:32 +00:00
parent 2cb49b97da
commit febd44ddd6
2 changed files with 8 additions and 4 deletions

View File

@ -399,9 +399,13 @@ re_syntax_base* basic_regex_creator<charT, traits>::append_set(
last = char_set.singles_end(); last = char_set.singles_end();
while(first != last) while(first != last)
{ {
charT* p = static_cast<charT*>(this->m_pdata->m_data.extend(sizeof(charT) * (first->second ? 3 : 2))); charT* p = static_cast<charT*>(this->m_pdata->m_data.extend(sizeof(charT) * (first->first ? 1 : first->second ? 3 : 2)));
p[0] = m_traits.translate(first->first, m_icase); p[0] = m_traits.translate(first->first, m_icase);
if(first->second) if(first->first)
{
p[0] = 0;
}
else if(first->second)
{ {
p[1] = m_traits.translate(first->second, m_icase); p[1] = m_traits.translate(first->second, m_icase);
p[2] = 0; p[2] = 0;

View File

@ -161,9 +161,9 @@ iterator BOOST_REGEX_CALL re_is_set_member(iterator next,
if(*p == static_cast<charT>(0)) if(*p == static_cast<charT>(0))
{ {
// treat null string as special case: // treat null string as special case:
if(traits_inst.translate(*ptr, icase) != *p) if(traits_inst.translate(*ptr, icase))
{ {
while(*p == static_cast<charT>(0))++p; ++p;
continue; continue;
} }
return set_->isnot ? next : (ptr == next) ? ++next : ptr; return set_->isnot ? next : (ptr == next) ? ++next : ptr;