diff options
| author | Sebastian Berg <sebastian@sipsolutions.net> | 2021-02-15 17:02:34 -0600 |
|---|---|---|
| committer | Sebastian Berg <sebastian@sipsolutions.net> | 2021-02-15 17:02:34 -0600 |
| commit | fe16f90d637e6b1e4f7835f286bb4ae40f76e753 (patch) | |
| tree | 73b3fcfbae21231b2164affcf6d62c810cd845e0 /numpy | |
| parent | 5ca0ef6272ef3eabe2feb4049b7cb05a52516495 (diff) | |
| download | numpy-fe16f90d637e6b1e4f7835f286bb4ae40f76e753.tar.gz | |
BUG: Fix tiny memory leaks when `like=` overrides are used
I thought I had fixed these leaks, but it appears I missed some.
We probably should backport this to 1.20.x (its simple), but the leaks
are also pretty harmless unless someone uses `like=` hundrets of
thousands of times in a running program (and its a new fetaure).
Diffstat (limited to 'numpy')
| -rw-r--r-- | numpy/core/src/multiarray/multiarraymodule.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/numpy/core/src/multiarray/multiarraymodule.c b/numpy/core/src/multiarray/multiarraymodule.c index 2c00c498b..7915c75be 100644 --- a/numpy/core/src/multiarray/multiarraymodule.c +++ b/numpy/core/src/multiarray/multiarraymodule.c @@ -1829,6 +1829,8 @@ array_empty(PyObject *NPY_UNUSED(ignored), PyObject *args, PyObject *kwds) array_function_result = array_implement_c_array_function_creation( "empty", args, kwds); if (array_function_result != Py_NotImplemented) { + Py_XDECREF(typecode); + npy_free_cache_dim_obj(shape); return array_function_result; } @@ -2026,6 +2028,8 @@ array_zeros(PyObject *NPY_UNUSED(ignored), PyObject *args, PyObject *kwds) array_function_result = array_implement_c_array_function_creation( "zeros", args, kwds); if (array_function_result != Py_NotImplemented) { + Py_XDECREF(typecode); + npy_free_cache_dim_obj(shape); return array_function_result; } @@ -2139,11 +2143,13 @@ array_fromfile(PyObject *NPY_UNUSED(ignored), PyObject *args, PyObject *keywds) array_function_result = array_implement_c_array_function_creation( "fromfile", args, keywds); if (array_function_result != Py_NotImplemented) { + Py_XDECREF(type); return array_function_result; } file = NpyPath_PathlikeToFspath(file); if (file == NULL) { + Py_XDECREF(type); return NULL; } @@ -2250,6 +2256,7 @@ array_frombuffer(PyObject *NPY_UNUSED(ignored), PyObject *args, PyObject *keywds array_function_result = array_implement_c_array_function_creation( "frombuffer", args, keywds); if (array_function_result != Py_NotImplemented) { + Py_XDECREF(type); return array_function_result; } |
