Open ndvbd opened 1 year ago
I solved the memory leak in the python wrapper. In the file aspell.2.c (or in aspell.c) the AspellWordList2PythonList while loop should be changed to:
while ( (word=aspell_string_enumeration_next(elements)) != 0) {
PyObject *py_word = Py_BuildValue("s", word);
int result = PyList_Append(list, py_word);
Py_DECREF(py_word);
if (result == -1) {
PyErr_SetString(PyExc_Exception, "It is almost impossible, but happend! Can't append element to the list.");
delete_aspell_string_enumeration(elements);
Py_DECREF(list);
return NULL;
}
}
Note that there is a memory leak also in the linux aspell itself, and it should be built using: https://github.com/GNUAspell/aspell/pull/601 before patching this python wrapper
Memory leak is created when running this code: