Fix UB when downcasting null pointers, use pointer_trait' specialized function

This commit is contained in:
Ion Gaztañaga
2023-05-02 22:42:29 +02:00
parent f11301c5b5
commit fc46064c29

View File

@ -591,7 +591,7 @@ inline typename pointer_traits<SlistNodePtr>::template rebind_pointer<Node>::typ
dcast_bucket_ptr(const SlistNodePtr &p)
{
typedef typename pointer_traits<SlistNodePtr>::template rebind_pointer<Node>::type node_ptr;
return pointer_traits<node_ptr>::pointer_to(static_cast<Node&>(*p));
return pointer_traits<node_ptr>::static_cast_from(p);
}
template<class NodeTraits>