Check for NULL pointer before calling *_ref() function in Python wrapper.

This commit is contained in:
Ghislain MARY 2014-08-04 17:52:30 +02:00
parent 6a191c2fb5
commit 0aca2d72fc

View file

@ -160,7 +160,11 @@ class MethodDefinition:
new_from_native_pointer_code = "\tpyresult = pylinphone_{return_type}_new_from_native_ptr(&pylinphone_{return_type}Type, cresult);\n".format(return_type=stripped_return_type)
if self.self_arg is not None and return_type_class['class_refcountable']:
ref_function = return_type_class['class_c_function_prefix'] + "ref"
ref_native_pointer_code = "\t{func}(({cast_type})cresult);\n".format(func=ref_function, cast_type=self.remove_const_from_complete_type(self.return_complete_type))
ref_native_pointer_code = \
""" if (cresult != NULL) {{
{func}(({cast_type})cresult);
}}
""".format(func=ref_function, cast_type=self.remove_const_from_complete_type(self.return_complete_type))
result_variable = 'pyresult'
else:
result_variable = 'cresult'