[libcxx-commits] [libcxxabi] [libc++abi] Don't do pointer arithmetic on nullptr (PR #119520)

via libcxx-commits libcxx-commits at lists.llvm.org
Tue Dec 10 23:56:03 PST 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-libcxxabi

Author: Vitaly Buka (vitalybuka)

<details>
<summary>Changes</summary>

`nullptr + offset` is possible after `!is_virtual` branch.

Fixes https://lab.llvm.org/buildbot/#/builders/85/builds/3200/steps/10/logs/stdio


---
Full diff: https://github.com/llvm/llvm-project/pull/119520.diff


1 Files Affected:

- (modified) libcxxabi/src/private_typeinfo.cpp (+1-1) 


``````````diff
diff --git a/libcxxabi/src/private_typeinfo.cpp b/libcxxabi/src/private_typeinfo.cpp
index 2f631041f74c94..8f6e8c6631de4c 100644
--- a/libcxxabi/src/private_typeinfo.cpp
+++ b/libcxxabi/src/private_typeinfo.cpp
@@ -593,7 +593,7 @@ __base_class_type_info::has_unambiguous_public_base(__dynamic_cast_info* info,
   }
     __base_type->has_unambiguous_public_base(
             info,
-            static_cast<char*>(adjustedPtr) + offset_to_base,
+            reinterpret_cast<void*>(reinterpret_cast<uintptr_t>(adjustedPtr) + offset_to_base),
             (__offset_flags & __public_mask) ? path_below : not_public_path);
 }
 

``````````

</details>


https://github.com/llvm/llvm-project/pull/119520


More information about the libcxx-commits mailing list