From 0aca2d72fc96408577cdb2b5348f51304c716c41 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Mon, 4 Aug 2014 17:52:30 +0200 Subject: [PATCH] Check for NULL pointer before calling *_ref() function in Python wrapper. --- tools/python/apixml2python/linphone.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tools/python/apixml2python/linphone.py b/tools/python/apixml2python/linphone.py index 784bec1f6..0a8c1f550 100644 --- a/tools/python/apixml2python/linphone.py +++ b/tools/python/apixml2python/linphone.py @@ -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'