Make wxSharedPtr::Release() really MT-safe.
Using wxAtomicDec() is not enough, its result also must be checked as it will return 0 only in one of the threads if multiple threads call it in parallel, while the old test for m_count==0 could pass for more than one thread, resulting in deleting the same pointer more than once. Closes #15227. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@74065 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -115,8 +115,7 @@ private:
|
||||
{
|
||||
if (m_ref)
|
||||
{
|
||||
wxAtomicDec( m_ref->m_count );
|
||||
if (m_ref->m_count == 0)
|
||||
if (!wxAtomicDec( m_ref->m_count ))
|
||||
{
|
||||
delete m_ref->m_ptr;
|
||||
delete m_ref;
|
||||
|
Reference in New Issue
Block a user