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: Py_DECREF lists once inserted in dicts. #226

Closed lsix closed 2 years ago

lsix commented 2 years ago

Along the creation of python dict, few lists are created and then inserted into the dict using PyDict_SetItemString/DictSafeSetItem. The latter internaly uses PyDict_SetItemString. This function does not steal a reference to its VAL argument, i.e. it increments the refcount of the list.

Once this is done, a call to Py_DECREF should be made to indicate that the c++ code does not own the list anymore. Not doing so caused few memory leaks.

lsix commented 2 years ago

I have rebased this PR as well.

schwehr commented 2 years ago

Thanks for the fixes!