[libc-commits] [libc] [libc] Fix undefined behavior for nan functions. (PR #106468)
Michael Jones via libc-commits
libc-commits at lists.llvm.org
Fri Aug 30 15:53:12 PDT 2024
================
@@ -1208,6 +1210,15 @@ template <class T> LIBC_INLINE StrToNumResult<T> strtonan(const char *arg) {
using FPBits = typename fputil::FPBits<T>;
using StorageType = typename FPBits::StorageType;
+#ifndef LIBC_HAS_SANITIZER
+ if (LIBC_UNLIKELY(arg == nullptr)) {
+ // Use volatile to prevent undefined behavior of dereferencing nullptr.
----------------
michaelrj-google wrote:
given that this problem is only likely to occur in the tests, does it make more sense to change the tests instead of adding this extra-explicit check here?
https://github.com/llvm/llvm-project/pull/106468
More information about the libc-commits
mailing list