Skip to content

Commit 2171fed

Browse files
committed
REF: DECREF of 'aval' if elemsize is not correct before return.
- PyArray_FromAny handles the refcnt of descr.
1 parent eafb208 commit 2171fed

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

devsupApp/src/dbfield.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -164,23 +164,19 @@ static int assign_array(DBADDR *paddr, PyObject *arr)
164164
}
165165

166166
Py_XINCREF(desc);
167-
if(!(aval = PyArray_FromAny(arr, desc, 1, 2, NPY_ARRAY_C_CONTIGUOUS | NPY_ARRAY_ALIGNED | NPY_ARRAY_WRITEABLE, arr))) {
168-
Py_XDECREF(desc);
167+
if(!(aval = PyArray_FromAny(arr, desc, 1, 2, NPY_ARRAY_C_CONTIGUOUS | NPY_ARRAY_ALIGNED | NPY_ARRAY_WRITEABLE, arr)))
169168
return 1;
170-
}
171169

172170
if(elemsize!=PyArray_ITEMSIZE((PyArrayObject *)aval)) {
173171
PyErr_Format(PyExc_AssertionError, "item size mismatch %u %u",
174-
elemsize, (unsigned)PyArray_ITEMSIZE((PyArrayObject *)aval) );
172+
elemsize, (unsigned)PyArray_ITEMSIZE((PyArrayObject *)aval));
175173
Py_DECREF(aval);
176-
Py_XDECREF(desc);
177174
return 1;
178175
}
179176

180177
memcpy(rawfield, PyArray_GETPTR1((PyArrayObject *)aval, 0), insize*elemsize);
181178

182179
Py_DECREF(aval);
183-
Py_XDECREF(desc);
184180

185181
if(paddr->special==SPC_DBADDR &&
186182
(prset=dbGetRset(paddr)) &&

0 commit comments

Comments
 (0)