summaryrefslogtreecommitdiff
path: root/numpy
diff options
context:
space:
mode:
Diffstat (limited to 'numpy')
-rw-r--r--numpy/core/src/multiarray/_multiarray_tests.c.src5
1 files changed, 3 insertions, 2 deletions
diff --git a/numpy/core/src/multiarray/_multiarray_tests.c.src b/numpy/core/src/multiarray/_multiarray_tests.c.src
index 3811e87a8..3c8caefce 100644
--- a/numpy/core/src/multiarray/_multiarray_tests.c.src
+++ b/numpy/core/src/multiarray/_multiarray_tests.c.src
@@ -677,11 +677,12 @@ create_custom_field_dtype(PyObject *NPY_UNUSED(mod), PyObject *args)
"invalid error argument to test function.");
}
if (PyArray_RegisterDataType(dtype) < 0) {
- /* Fix original type in the error_path == 2 case. */
+ /* Fix original type in the error_path == 2 case and delete it */
Py_SET_TYPE(dtype, original_type);
+ Py_DECREF(dtype);
return NULL;
}
- Py_INCREF(dtype);
+ Py_INCREF(dtype); /* hold on to the original (leaks a reference) */
return (PyObject *)dtype;
}