]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
pidl:Python: initialize pointers and add 'result' at the end
authorStefan Metzmacher <metze@samba.org>
Tue, 28 Jan 2025 09:19:09 +0000 (10:19 +0100)
committerJule Anger <janger@samba.org>
Mon, 3 Feb 2025 14:53:10 +0000 (14:53 +0000)
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14213

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
(cherry picked from commit 9dfb0ed8d29bd4a9146cf38bd63c4bb55b5faf73)

pidl/lib/Parse/Pidl/Samba4/Python.pm

index 44c7e70507e15cbcc899b16ab4f2966a6947b1e3..e024b19a19adab31528f8ff235044cb816bdee77 100644 (file)
@@ -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}";