Commit 88c902d1 authored by Ghislain MARY's avatar Ghislain MARY
Browse files

Fix memory leak of returned strings in Python module.

parent a2b93b20
......@@ -382,6 +382,7 @@ class MethodDefinition:
from_native_pointer_code = ''
convert_from_code = ''
build_value_code = ''
cfree_code = ''
result_variable = ''
if self.return_complete_type != 'void':
if self.build_value_format == 'O':
......@@ -400,16 +401,20 @@ class MethodDefinition:
result_variable = 'cresult'
if result_variable != '':
build_value_code = "pyret = Py_BuildValue(\"{fmt}\", {result_variable});".format(fmt=self.build_value_format, result_variable=result_variable)
if self.return_complete_type == 'char *':
cfree_code = 'ms_free(cresult);';
body = \
""" {c_function_call_code}
pylinphone_dispatch_messages();
{from_native_pointer_code}
{convert_from_code}
{build_value_code}
{cfree_code}
""".format(c_function_call_code=c_function_call_code,
from_native_pointer_code=from_native_pointer_code,
convert_from_code=convert_from_code,
build_value_code=build_value_code)
build_value_code=build_value_code,
cfree_code=cfree_code)
return body
def format_return_trace(self):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment