From 0b6892044f39ee2dfe5265f4ff9cec2587d21e39 Mon Sep 17 00:00:00 2001 From: Benjamin Dauvergne Date: Sat, 20 Jun 2020 09:16:22 +0200 Subject: [PATCH 21/21] python: do not leak out_pyvalue if method call protocol is not respected (#44287) --- bindings/python/lang.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/bindings/python/lang.py b/bindings/python/lang.py index b3f9f764..a8734ef7 100644 --- a/bindings/python/lang.py +++ b/bindings/python/lang.py @@ -1039,7 +1039,12 @@ register_constants(PyObject *d) for f, arg in zip(parse_tuple_format, m.args): if is_out(arg): self.return_value(fd, arg, return_var_name = arg[1], return_pyvar_name = 'out_pyvalue') - print_(' PyList_SetItem(cvt_%s_out, 0, out_pyvalue);' % arg[1], file=fd) + + print_(' EXIT_IF_FAIL(%s);' % arg[1], file=fd) + print_(' if (PyList_SetItem(cvt_%s_out, 0, out_pyvalue) == -1) {' % arg[1], file=fd) + print_(' ok = 0;', file=fd) + print_(' Py_XDECREF(out_pyvalue);', file=fd) + print_(' }', file=fd) elif arg[0] == 'GList*': qualifier = arg[2].get('element-type') if is_cstring(qualifier): -- 2.26.2