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

Vitaly Buka via libcxx-commits libcxx-commits at lists.llvm.org
Tue Dec 10 23:55:27 PST 2024


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

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

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


>From 5a6efa8551c7441e5b94a899b60771f5a47d5655 Mon Sep 17 00:00:00 2001
From: Vitaly Buka <vitalybuka at google.com>
Date: Tue, 10 Dec 2024 23:55:10 -0800
Subject: [PATCH] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20initia?=
 =?UTF-8?q?l=20version?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Created using spr 1.3.4
---
 libcxxabi/src/private_typeinfo.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

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);
 }
 



More information about the libcxx-commits mailing list