Skip to content

Commit

Permalink
BUG: Decref loadtxt converters when done
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
seberg authored and charris committed Jun 14, 2022
1 parent 9f26811 commit 3e104db
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions numpy/core/src/multiarray/textreading/rows.c
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 3e104db

Please sign in to comment.