summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Berg <sebastian@sipsolutions.net>2020-11-29 15:54:18 -0600
committerSebastian Berg <sebastian@sipsolutions.net>2020-11-29 15:58:14 -0600
commit4234327caccd76a0fe62a89162cbf0b122e2f83a (patch)
treed2fc1e04dcea02e7e14048df397fd85d241da53e
parent33da69fcb0abb39ff987c148b6b74a02183c60d6 (diff)
downloadnumpy-4234327caccd76a0fe62a89162cbf0b122e2f83a.tar.gz
TST: Do not leak reference/object in error-test path
The other path must leak, since dtype registration is permanent (at least I think so).
-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;
}