Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f94ffd7

Browse files
committed
Use XINCREF in copy constructor and subview constructor, since arr may be NULL
1 parent bae42a8 commit f94ffd7

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/numpy_cpp.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ class array_view : public detail::array_view_accessors<array_view, T, ND>
370370
array_view(const array_view &other, bool contiguous = false) : m_arr(NULL), m_data(NULL)
371371
{
372372
m_arr = other.m_arr;
373-
Py_INCREF(m_arr);
373+
Py_XINCREF(m_arr);
374374
m_data = other.m_data;
375375
m_shape = other.m_shape;
376376
m_strides = other.m_strides;
@@ -379,7 +379,7 @@ class array_view : public detail::array_view_accessors<array_view, T, ND>
379379
array_view(PyArrayObject *arr, char *data, npy_intp *shape, npy_intp *strides)
380380
{
381381
m_arr = arr;
382-
Py_INCREF(arr);
382+
Py_XINCREF(arr);
383383
m_data = data;
384384
m_shape = shape;
385385
m_strides = strides;

0 commit comments

Comments
 (0)