Skip to content

Commit 01f13a9

Browse files
committed
fix reference counting error
1 parent ff238ae commit 01f13a9

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

stringdtype/stringdtype/src/dtype.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,11 @@ stringdtype_setitem(StringDTypeObject *NPY_UNUSED(descr), PyObject *obj,
125125

126126
// copies contents of val into item_val->buf
127127
int res = ssnewlen(val, length, (ss *)dataptr);
128+
128129
// val_obj must stay alive until here to ensure *val* doesn't get
129130
// deallocated
130131
Py_DECREF(val_obj);
132+
131133
if (res == -1) {
132134
PyErr_NoMemory();
133135
return -1;
@@ -137,7 +139,6 @@ stringdtype_setitem(StringDTypeObject *NPY_UNUSED(descr), PyObject *obj,
137139
assert(0);
138140
}
139141

140-
Py_DECREF(val_obj);
141142
return 0;
142143
}
143144

0 commit comments

Comments
 (0)