Skip to content

Commit

Permalink
Fix undefined behavior in syntax_option_type::operator~ and match_fla…
Browse files Browse the repository at this point in the history
…g_type::operator./a.out Found by UBSan

llvm-svn: 177693
  • Loading branch information
Marshall Clow committed Mar 22, 2013
1 parent eaef89b commit 1c2c986
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions libcxx/include/regex
Expand Up @@ -764,7 +764,7 @@ _LIBCPP_CONSTEXPR
syntax_option_type
operator~(syntax_option_type __x)
{
return syntax_option_type(~int(__x));
return syntax_option_type(~int(__x) & 0x1FF);
}

inline _LIBCPP_INLINE_VISIBILITY
Expand Down Expand Up @@ -840,7 +840,7 @@ _LIBCPP_CONSTEXPR
match_flag_type
operator~(match_flag_type __x)
{
return match_flag_type(~int(__x));
return match_flag_type(~int(__x) & 0x0FFF);
}

inline _LIBCPP_INLINE_VISIBILITY
Expand Down

0 comments on commit 1c2c986

Please sign in to comment.