diff options
| author | Sebastian Berg <sebastian@sipsolutions.net> | 2022-06-14 13:33:45 -0700 |
|---|---|---|
| committer | Sebastian Berg <sebastian@sipsolutions.net> | 2022-06-14 13:33:45 -0700 |
| commit | 820c6f4c5713a7ef92d48c66f8a58abd23cf6396 (patch) | |
| tree | 4d311fb095eb83f0f0d8c2a4ad60cf82e59caf25 /numpy | |
| parent | 5d6943077f44bd7fda5f36106af44625f215c9c0 (diff) | |
| download | numpy-820c6f4c5713a7ef92d48c66f8a58abd23cf6396.tar.gz | |
BUG: Decref `loadtxt` converters when done
Possibly they were just not incref'd in an earlier version of the
code. But incref'ing seems right, so this adds the proper decref
loop.
Diffstat (limited to 'numpy')
| -rw-r--r-- | numpy/core/src/multiarray/textreading/rows.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/numpy/core/src/multiarray/textreading/rows.c b/numpy/core/src/multiarray/textreading/rows.c index e30ff835e..86c01d189 100644 --- a/numpy/core/src/multiarray/textreading/rows.c +++ b/numpy/core/src/multiarray/textreading/rows.c @@ -432,7 +432,12 @@ read_rows(stream *s, } tokenizer_clear(&ts); - PyMem_FREE(conv_funcs); + if (conv_funcs != NULL) { + for (Py_ssize_t i = 0; i < actual_num_fields; i++) { + Py_XDECREF(conv_funcs[i]); + } + PyMem_FREE(conv_funcs); + } if (data_array == NULL) { assert(row_count == 0 && result_shape[0] == 0); @@ -474,7 +479,12 @@ read_rows(stream *s, return data_array; error: - PyMem_FREE(conv_funcs); + if (conv_funcs != NULL) { + for (Py_ssize_t i = 0; i < actual_num_fields; i++) { + Py_XDECREF(conv_funcs[i]); + } + PyMem_FREE(conv_funcs); + } tokenizer_clear(&ts); Py_XDECREF(data_array); return NULL; |
