Skip to content

Commit

Permalink
Avoid potential null dereference in annotated_ptr
Browse files Browse the repository at this point in the history
Fixes [BUG]: UB in annotated_ptr #2942
  • Loading branch information
miscco committed Nov 25, 2024
1 parent 80031e2 commit 7d4d5cf
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions libcudacxx/include/cuda/annotated_ptr
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,10 @@ public:

_CCCL_HOST_DEVICE pointer get() const noexcept
{
if (__repr == nullptr)
{
return nullptr;
}
constexpr bool __is_shared = std::is_same<_Property, access_property::shared>::value;
return __is_shared ? __repr : &(*annotated_ptr<value_type, access_property::global>(__repr));
}
Expand Down

0 comments on commit 7d4d5cf

Please sign in to comment.