Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 59cd8237 authored by Hans Boehm's avatar Hans Boehm Committed by Gerrit Code Review
Browse files

Merge "Check sp<>::clear() for data races"

parents 572d3334 f4f76205
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -228,8 +228,10 @@ void sp<T>::force_set(T* other) {

template<typename T>
void sp<T>::clear() {
    if (m_ptr) {
        m_ptr->decStrong(this);
    T* oldPtr(*const_cast<T* volatile*>(&m_ptr));
    if (oldPtr) {
        oldPtr->decStrong(this);
        if (oldPtr != *const_cast<T* volatile*>(&m_ptr)) sp_report_race();
        m_ptr = nullptr;
    }
}