[libc-commits] [libc] [libc] Fix undefined behavior for nan functions. (PR #106468)
Michael Jones via libc-commits
libc-commits at lists.llvm.org
Wed Sep 4 16:21:00 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:
That's a fair point. In that case we should create a generic way to do nullptr checks so it can be used in other places, and also guard it behind a hardening macro so it can be turned off on space-sensitive systems.
https://github.com/llvm/llvm-project/pull/106468
More information about the libc-commits
mailing list