[libcxx] r177693 - Fix undefined behavior in syntax_option_type::operator~ and match_flag_type::operator./a.out Found by UBSan

Marshall Clow mclow at qualcomm.com
Thu Mar 21 19:13:55 PDT 2013


Author: marshall
Date: Thu Mar 21 21:13:55 2013
New Revision: 177693

URL: http://llvm.org/viewvc/llvm-project?rev=177693&view=rev
Log:
Fix undefined behavior in syntax_option_type::operator~ and match_flag_type::operator./a.out  Found by UBSan

Modified:
    libcxx/trunk/include/regex

Modified: libcxx/trunk/include/regex
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/regex?rev=177693&r1=177692&r2=177693&view=diff
==============================================================================
--- libcxx/trunk/include/regex (original)
+++ libcxx/trunk/include/regex Thu Mar 21 21:13:55 2013
@@ -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
@@ -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





More information about the cfe-commits mailing list