diff options
author | Stefan Metzmacher <metze@samba.org> | 2016-09-12 15:12:50 +0200 |
---|---|---|
committer | Andreas Schneider <asn@cryptomilk.org> | 2016-10-26 11:20:18 +0200 |
commit | b728c63bcb5860aed2db43139d191bc149ceba83 (patch) | |
tree | 06cc22b346c331e79258c155cf1c926a0727a19a /pidl | |
parent | ff947f2765a1351fa548437b1189b2025c571b50 (diff) | |
download | samba-b728c63bcb5860aed2db43139d191bc149ceba83.tar.gz |
pidl:Python: check the return values of talloc_ptrtype()
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
Diffstat (limited to 'pidl')
-rw-r--r-- | pidl/lib/Parse/Pidl/Samba4/Python.pm | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/pidl/lib/Parse/Pidl/Samba4/Python.pm b/pidl/lib/Parse/Pidl/Samba4/Python.pm index 07c18de3fb5..53937a29c64 100644 --- a/pidl/lib/Parse/Pidl/Samba4/Python.pm +++ b/pidl/lib/Parse/Pidl/Samba4/Python.pm @@ -570,6 +570,12 @@ sub PythonFunctionPackIn($$$) my $val = "PyList_GET_SIZE($py_var)"; if ($e->{LEVELS}[0]->{TYPE} eq "POINTER") { $self->pidl("r->in.$e->{NAME} = talloc_ptrtype(r, r->in.$e->{NAME});"); + $self->pidl("if (r->in.$e->{NAME} == NULL) {"); + $self->indent; + $self->pidl("PyErr_NoMemory();"); + $self->pidl($fail); + $self->deindent; + $self->pidl("}"); $self->pidl("*r->in.$e->{NAME} = $val;"); } else { $self->pidl("r->in.$e->{NAME} = $val;"); @@ -1239,9 +1245,21 @@ sub ConvertObjectFromPythonLevel($$$$$$$$) # then this is where we would need to allocate it if ($l->{POINTER_TYPE} eq "ref") { $self->pidl("$var_name = talloc_ptrtype($mem_ctx, $var_name);"); + $self->pidl("if ($var_name == NULL) {"); + $self->indent; + $self->pidl("PyErr_NoMemory();"); + $self->pidl($fail); + $self->deindent; + $self->pidl("}"); } elsif ($nl->{TYPE} eq "DATA" and Parse::Pidl::Typelist::is_scalar($nl->{DATA_TYPE}) and not Parse::Pidl::Typelist::scalar_is_reference($nl->{DATA_TYPE})) { $self->pidl("$var_name = talloc_ptrtype($mem_ctx, $var_name);"); + $self->pidl("if ($var_name == NULL) {"); + $self->indent; + $self->pidl("PyErr_NoMemory();"); + $self->pidl($fail); + $self->deindent; + $self->pidl("}"); } else { $self->pidl("$var_name = NULL;"); } |