From dda88007ebf3d8dda59da1ab60365bc9153b85ea Mon Sep 17 00:00:00 2001 From: khizmax Date: Wed, 8 Mar 2017 11:37:21 +0300 Subject: [PATCH] [UBsan] fixed UB --- cds/intrusive/ellen_bintree_rcu.h | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/cds/intrusive/ellen_bintree_rcu.h b/cds/intrusive/ellen_bintree_rcu.h index 50e9cf02..b948cc8e 100644 --- a/cds/intrusive/ellen_bintree_rcu.h +++ b/cds/intrusive/ellen_bintree_rcu.h @@ -552,10 +552,14 @@ namespace cds { namespace intrusive { protected: //@cond - static void free_leaf_node( value_type * p ) + static void free_leaf_node( value_type* p ) { disposer()( p ); } + static void free_leaf_node_void( void* p ) + { + free_leaf_node( reinterpret_cast( p )); + } internal_node * alloc_internal_node() const { @@ -565,10 +569,14 @@ namespace cds { namespace intrusive { return pNode; } - static void free_internal_node( internal_node * pNode ) + static void free_internal_node( internal_node* pNode ) { cxx_node_allocator().Delete( pNode ); } + static void free_internal_node_void( void* pNode ) + { + free_internal_node( reinterpret_cast( pNode )); + } struct internal_node_deleter { void operator()( internal_node * p) const @@ -585,10 +593,14 @@ namespace cds { namespace intrusive { return cxx_update_desc_allocator().New(); } - static void free_update_desc( update_desc * pDesc ) + static void free_update_desc( update_desc* pDesc ) { cxx_update_desc_allocator().Delete( pDesc ); } + static void free_update_desc_void( void* pDesc ) + { + free_update_desc( reinterpret_cast( pDesc ) ); + } class retired_list { @@ -615,21 +627,19 @@ namespace cds { namespace intrusive { cds::urcu::retired_ptr operator *() { if ( m_pUpdate ) { - return cds::urcu::retired_ptr( reinterpret_cast( m_pUpdate ), - reinterpret_cast( free_update_desc )); + return cds::urcu::retired_ptr( reinterpret_cast( m_pUpdate ), free_update_desc_void ); } if ( m_pNode ) { if ( m_pNode->is_leaf()) { return cds::urcu::retired_ptr( reinterpret_cast( node_traits::to_value_ptr( static_cast( m_pNode ))), - reinterpret_cast< cds::urcu::free_retired_ptr_func>( free_leaf_node )); + free_leaf_node_void ); } else { return cds::urcu::retired_ptr( reinterpret_cast( static_cast( m_pNode )), - reinterpret_cast( free_internal_node )); + free_internal_node_void ); } } - return cds::urcu::retired_ptr( nullptr, - reinterpret_cast( free_update_desc )); + return cds::urcu::retired_ptr( nullptr, free_update_desc_void ); } void operator ++() -- 2.34.1