From 2778130d45006a8cc04c11814070839e922bcc31 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 6 Jan 2011 13:45:55 +0100 Subject: pidl:Samba4/Python: fix memory leak in _ndr_print functions metze Autobuild-User: Stefan Metzmacher Autobuild-Date: Thu Jan 6 14:34:31 CET 2011 on sn-devel-104 --- pidl/lib/Parse/Pidl/Samba4/Python.pm | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'pidl') diff --git a/pidl/lib/Parse/Pidl/Samba4/Python.pm b/pidl/lib/Parse/Pidl/Samba4/Python.pm index d6eab12c5c..7f6f94e748 100644 --- a/pidl/lib/Parse/Pidl/Samba4/Python.pm +++ b/pidl/lib/Parse/Pidl/Samba4/Python.pm @@ -297,9 +297,14 @@ sub PythonStruct($$$$$$) $self->pidl("{"); $self->indent; $self->pidl("$cname *object = ($cname *)py_talloc_get_ptr(py_obj);"); + $self->pidl("PyObject *ret;"); $self->pidl("char *retstr;"); + $self->pidl(""); $self->pidl("retstr = ndr_print_struct_string(py_talloc_get_mem_ctx(py_obj), (ndr_print_fn_t)ndr_print_$name, \"$name\", object);"); - $self->pidl("return PyString_FromString(retstr);"); + $self->pidl("ret = PyString_FromString(retstr);"); + $self->pidl("talloc_free(retstr);"); + $self->pidl(""); + $self->pidl("return ret;"); $self->deindent; $self->pidl("}"); $self->pidl(""); -- cgit