Skip to content

Commit 06e809a

Browse files
committed
Fixed release not reseting the pointer to null
1 parent 41f9ed7 commit 06e809a

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

include/oup/observable_unique_ptr.hpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,11 +302,14 @@ class observable_unique_ptr {
302302
/** \return A pointer to the un-managed object
303303
*/
304304
T* release() noexcept {
305+
T* old_ptr = pointer;
305306
if (pointer) {
306307
pop_ref_();
308+
block = nullptr;
309+
pointer = nullptr;
307310
}
308311

309-
return pointer;
312+
return old_ptr;
310313
}
311314

312315
/// Get a non-owning raw pointer to the pointed object, or nullptr if deleted.

0 commit comments

Comments
 (0)