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: samba-4.20.8~48 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d1998e201af03f58d8e48278d2936311865b617d;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 (cherry picked from commit 9dfb0ed8d29bd4a9146cf38bd63c4bb55b5faf73) --- diff --git a/pidl/lib/Parse/Pidl/Samba4/Python.pm b/pidl/lib/Parse/Pidl/Samba4/Python.pm index 44c7e70507e..e024b19a19a 100644 --- a/pidl/lib/Parse/Pidl/Samba4/Python.pm +++ b/pidl/lib/Parse/Pidl/Samba4/Python.pm @@ -970,12 +970,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++; } @@ -988,7 +987,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);"); @@ -999,6 +999,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}";