Skip to content

Commit

Permalink
External pointer premature release
Browse files Browse the repository at this point in the history
r-lib/cpp11#423

This reverts commit 1b698e533ea7c7003cb610a5f5f7e5a47966c59d.
  • Loading branch information
krlmlr committed Dec 7, 2024
1 parent 4f4a3a8 commit d7886e3
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions inst/include/cpp11/external_pointer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,15 @@ class external_pointer {
data_ = safe[Rf_shallow_duplicate](rhs.data_);
}

external_pointer(external_pointer&& rhs) { reset(rhs.release()); }
external_pointer(external_pointer&& rhs) {
data_ = rhs.data_;
rhs.data_ = R_NilValue;
}

external_pointer& operator=(external_pointer&& rhs) noexcept { reset(rhs.release()); }
external_pointer& operator=(external_pointer&& rhs) noexcept {
data_ = rhs.data_;
rhs.data_ = R_NilValue;
}

external_pointer& operator=(std::nullptr_t) noexcept { reset(); };

Expand Down

0 comments on commit d7886e3

Please sign in to comment.