Commit d73291f1 authored by Dominik Charousset's avatar Dominik Charousset

Fix possible invalid write in intrusive_ptr

parent 483a06aa
...@@ -87,10 +87,11 @@ class intrusive_ptr : detail::comparable<intrusive_ptr<T>>, ...@@ -87,10 +87,11 @@ class intrusive_ptr : detail::comparable<intrusive_ptr<T>>,
} }
void reset(pointer new_value = nullptr, bool add_ref = true) { void reset(pointer new_value = nullptr, bool add_ref = true) {
if (m_ptr) { auto old = m_ptr;
m_ptr->deref();
}
set_ptr(new_value, add_ref); set_ptr(new_value, add_ref);
if (old) {
old->deref();
}
} }
template <class... Ts> template <class... Ts>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment