Skip to content

Commit da26852

Browse files
authored
Merge pull request xtensor-stack#157 from wolfv/fix_leak
fix memory leaks in pytensor constructor and copy constructor
2 parents e875139 + 8c1278a commit da26852

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

include/xtensor-python/pytensor.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ namespace xt
342342
*/
343343
template <class T, std::size_t N, layout_type L>
344344
inline pytensor<T, N, L>::pytensor(const self_type& rhs)
345-
: self_type()
345+
: base_type(), semantic_base(rhs)
346346
{
347347
init_tensor(rhs.shape(), rhs.strides());
348348
std::copy(rhs.storage().cbegin(), rhs.storage().cend(), this->storage().begin());
@@ -416,7 +416,7 @@ namespace xt
416416
auto dtype = pybind11::detail::npy_format_descriptor<T>::dtype();
417417

418418
auto tmp = pybind11::reinterpret_steal<pybind11::object>(
419-
PyArray_NewFromDescr(&PyArray_Type, (PyArray_Descr*) dtype.ptr(), static_cast<int>(shape.size()),
419+
PyArray_NewFromDescr(&PyArray_Type, (PyArray_Descr*) dtype.release().ptr(), static_cast<int>(shape.size()),
420420
const_cast<npy_intp*>(shape.data()), python_strides,
421421
nullptr, flags, nullptr));
422422

0 commit comments

Comments
 (0)