From: Stefan Metzmacher Date: Tue, 28 Jan 2025 09:19:09 +0000 (+0100) Subject: pidl:Python: initialize pointers and add 'result' at the end X-Git-Tag: tdb-1.4.13~73 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=9dfb0ed8d29bd4a9146cf38bd63c4bb55b5faf73;p=thirdparty%2Fsamba.git pidl:Python: initialize pointers and add 'result' at the end BUG: https://bugzilla.samba.org/show_bug.cgi?id=14213 Signed-off-by: Stefan Metzmacher Reviewed-by: Douglas Bagnall --- diff --git a/pidl/lib/Parse/Pidl/Samba4/Python.pm b/pidl/lib/Parse/Pidl/Samba4/Python.pm index 4b0071404cd..664faa3d209 100644 --- a/pidl/lib/Parse/Pidl/Samba4/Python.pm +++ b/pidl/lib/Parse/Pidl/Samba4/Python.pm @@ -1020,12 +1020,11 @@ sub PythonFunctionUnpackOut($$$) $self->pidl("static PyObject *$outfnname(struct $fn->{NAME} *r)"); $self->pidl("{"); $self->indent; - $self->pidl("PyObject *result;"); foreach my $e (@{$fn->{ELEMENTS}}) { next unless (grep(/out/,@{$e->{DIRECTION}})); next if (($metadata_args->{in}->{$e->{NAME}} and grep(/in/, @{$e->{DIRECTION}})) or ($metadata_args->{out}->{$e->{NAME}}) and grep(/out/, @{$e->{DIRECTION}})); - $self->pidl("PyObject *py_$e->{NAME};"); + $self->pidl("PyObject *py_$e->{NAME} = NULL;"); $result_size++; } @@ -1038,7 +1037,8 @@ sub PythonFunctionUnpackOut($$$) $result_size++; } - my $i = 0; + $self->pidl("PyObject *result = NULL;"); + $self->pidl(""); if ($result_size > 1) { $self->pidl("result = PyTuple_New($result_size);"); @@ -1049,6 +1049,8 @@ sub PythonFunctionUnpackOut($$$) $signature .= "None"; } + my $i = 0; + foreach my $e (@{$fn->{ELEMENTS}}) { next if ($metadata_args->{out}->{$e->{NAME}}); my $py_name = "py_$e->{NAME}";