schwehr / libais

C++ decoder for Automatic Identification System for tracking ships and decoding maritime information
Other
215 stars 94 forks source link

ais_py.cpp: Fix usage of PyList_SetItem #223

Closed lsix closed 2 years ago

lsix commented 2 years ago

PyList_SetItem takes the ownership of its last argument[1]. Therefore, Creating a PyObject, passing it to PyList_SetItem and then calling Py_DECREF is an error.

Also removes a comment that was unsure of the behavior of PyList_SetItem regarding memory leak.

[1] https://docs.python.org/3/c-api/list.html#c.PyList_SetItem