Skip to content

Commit 56b04a8

Browse files
committed
Use PyList_GetItemRef for thread safety purposes
1 parent a3bc056 commit 56b04a8

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

Modules/_zstd/_zstdmodule.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,8 +230,9 @@ _zstd__train_dict_impl(PyObject *module, PyBytesObject *samples_bytes,
230230

231231
sizes_sum = 0;
232232
for (i = 0; i < chunks_number; i++) {
233-
PyObject *size = PyList_GET_ITEM(samples_size_list, i);
233+
PyObject *size = PyList_GetItemRef(samples_size_list, i);
234234
chunk_sizes[i] = PyLong_AsSize_t(size);
235+
Py_DECREF(size);
235236
if (chunk_sizes[i] == (size_t)-1 && PyErr_Occurred()) {
236237
PyErr_SetString(PyExc_ValueError,
237238
"Items in samples_size_list should be an int "

0 commit comments

Comments
 (0)