diff --git a/libutils/include/utils/StrongPointer.h b/libutils/include/utils/StrongPointer.h index 360fce509..3abce1705 100644 --- a/libutils/include/utils/StrongPointer.h +++ b/libutils/include/utils/StrongPointer.h @@ -228,8 +228,10 @@ void sp::force_set(T* other) { template void sp::clear() { - if (m_ptr) { - m_ptr->decStrong(this); + T* oldPtr(*const_cast(&m_ptr)); + if (oldPtr) { + oldPtr->decStrong(this); + if (oldPtr != *const_cast(&m_ptr)) sp_report_race(); m_ptr = nullptr; } }