Fix memory leaks remaining in code.

This commit is contained in:
Danila Fedorin 2017-05-05 22:54:51 -07:00
parent 46f52665cb
commit 9eb13b0ca8

View File

@ -6,6 +6,7 @@ static void _pyliblex_free_eval(PyObject* object){
eval_config* config = PyCapsule_GetPointer(object, NULL);
if(config){
liblex_result result = eval_config_free(config);
free(config);
if(result != LIBLEX_SUCCESS){
PyErr_NoMemory();
}
@ -69,9 +70,10 @@ static int _pyliblex_add_match(void* data, va_list args){
}
if(tuple) {
if(return_code != 0) Py_DECREF(tuple);
else return_code = PyList_Append(list, tuple);
if(return_code == 0) return_code = PyList_Append(list, tuple);
Py_DECREF(tuple);
}
return return_code;
}
static PyObject* pyliblex_lex(PyObject* self, PyObject* args){