Skip to content

Commit 5687b33

Browse files
dean0x7dwjakob
authored andcommitted
Fix negative refcount in PyCapsule destructor
1 parent 620a808 commit 5687b33

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

include/pybind11/eigen.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ handle eigen_ref_array(Type &src, handle parent = none()) {
229229
// not the Type of the pointer given is const.
230230
template <typename props, typename Type, typename = enable_if_t<is_eigen_dense_plain<Type>::value>>
231231
handle eigen_encapsulate(Type *src) {
232-
capsule base(src, [](PyObject *o) { delete reinterpret_steal<capsule>(o).operator Type*(); });
232+
capsule base(src, [](PyObject *o) { delete static_cast<Type *>(PyCapsule_GetPointer(o, nullptr)); });
233233
return eigen_ref_array<props>(*src, base);
234234
}
235235

0 commit comments

Comments
 (0)