Commit 767f4bdc authored by Christoph Groth's avatar Christoph Groth
Browse files

fix all refcounting leaks that show up when running the tests

parent e8a39e6e
......@@ -1058,6 +1058,7 @@ PyObject *get_dtype_py(PyObject *self, void *)
};
int dtype = int(get_dtype(self));
assert(dtype < int(NONE));
Py_INCREF(dtypes[dtype]);
return dtypes[dtype];
}
......@@ -1500,6 +1501,7 @@ PyObject *array_from_arraylike(PyObject *in, Dtype *dtype, Dtype dtype_min,
find_type ? &dt : 0) == 0) {
if (as_matrix && ndim != 2) {
if (ndim > 2) {
for (int d = 0; d < ndim; ++d) Py_DECREF(seqs[d]);
PyErr_SetString(PyExc_ValueError,
"Matrix must be 2-dimensional.");
return 0;
......
......@@ -218,7 +218,9 @@ PyObject *transpose(PyObject *, PyObject *args)
Dtype dtype = NONE;
a = array_from_arraylike(a, &dtype);
if (!a) return 0;
return transpose_dtable[int(dtype)](a, 0);
PyObject *result = transpose_dtable[int(dtype)](a, 0);
Py_DECREF(a);
return result;
}
PyDoc_STRVAR(transpose_doc,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment