diff options
author | Douglas Bagnall <douglas.bagnall@catalyst.net.nz> | 2019-08-01 23:29:55 +0000 |
---|---|---|
committer | Noel Power <npower@samba.org> | 2019-08-06 18:17:11 +0000 |
commit | fe9b12b274028a1310ac6c59cc56ac36bb40ef5e (patch) | |
tree | c691af4fe6ae7a12b57e8b592b62aa8be1177139 /pidl | |
parent | d6a82edd19b82d99401a27dbc6fe10121142e431 (diff) | |
download | samba-fe9b12b274028a1310ac6c59cc56ac36bb40ef5e.tar.gz |
pidl/ndr/python: avoid memory errors in getsetters
This:
$ python3 -c'from samba.dcerpc import lsa; x = lsa.EnumAccounts(); x.in_handle'
should not raise a MemoryError, which is very unfriendly given that
'x.in_handle' is just named, not called, as far as the user is
concerned. Returning None is the proper thing.
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Noel Power <npower@samba.org>
Autobuild-User(master): Noel Power <npower@samba.org>
Autobuild-Date(master): Tue Aug 6 18:17:11 UTC 2019 on sn-devel-184
Diffstat (limited to 'pidl')
-rw-r--r-- | pidl/lib/Parse/Pidl/Samba4/Python.pm | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/pidl/lib/Parse/Pidl/Samba4/Python.pm b/pidl/lib/Parse/Pidl/Samba4/Python.pm index 97c417adf35..8d5de31e7bb 100644 --- a/pidl/lib/Parse/Pidl/Samba4/Python.pm +++ b/pidl/lib/Parse/Pidl/Samba4/Python.pm @@ -201,6 +201,14 @@ sub PythonElementGetSet($$$$$$) { $self->indent; $self->pidl("$cname *object = ($cname *)pytalloc_get_ptr(obj);"); $self->pidl("PyObject *py_$e->{NAME};"); + my $l = $e->{LEVELS}[0]; + if ($l->{TYPE} eq "POINTER") { + $self->pidl("if ($varname == NULL) {"); + $self->indent; + $self->pidl("Py_RETURN_NONE;"); + $self->deindent; + $self->pidl("}"); + } $self->ConvertObjectToPython("pytalloc_get_mem_ctx(obj)", $env, $e, $varname, "py_$e->{NAME}", "return NULL;"); $self->pidl("return py_$e->{NAME};"); $self->deindent; |