[libc][Obvious] Fix except flags reading overflow detected by asan.

This commit is contained in:
Siva Chandra Reddy
2021-03-13 16:30:01 -08:00
parent 7d38a91a7f
commit 7c0179129f

View File

@@ -20,7 +20,7 @@ LLVM_LIBC_FUNCTION(int, fesetexceptflag,
// can fit in int type.
static_assert(sizeof(int) >= sizeof(fexcept_t),
"fexcept_t value cannot fit in an int value.");
int excepts_to_set = *reinterpret_cast<const int *>(flagp) & excepts;
int excepts_to_set = static_cast<const int>(*flagp) & excepts;
return fputil::setExcept(excepts_to_set);
}