diff options
author | Guy Harris <guy@alum.mit.edu> | 2017-09-24 21:17:03 -0700 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2017-09-25 04:17:59 +0000 |
commit | 856ce750606cb85427d65e67905091998e4f5976 (patch) | |
tree | 174662e28f109a5952f00340c3a5c09042ccf379 | |
parent | da01add6622688a682cec5d89a99f58e90f8e5fc (diff) |
pidl:Python: check the return values of talloc_ptrtype()
Pick up change from Samba:
commit b728c63bcb5860aed2db43139d191bc149ceba83
Author: Stefan Metzmacher <metze@samba.org>
Date: Mon Sep 12 15:12:50 2016 +0200
pidl:Python: check the return values of talloc_ptrtype()
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
Change-Id: Icfe8837b5b998e3c5c4ea98df21cf620f53cdcd7
Reviewed-on: https://code.wireshark.org/review/23706
Reviewed-by: Guy Harris <guy@alum.mit.edu>
-rw-r--r-- | tools/pidl/lib/Parse/Pidl/Samba4/Python.pm | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/tools/pidl/lib/Parse/Pidl/Samba4/Python.pm b/tools/pidl/lib/Parse/Pidl/Samba4/Python.pm index 07c18de3fb..53937a29c6 100644 --- a/tools/pidl/lib/Parse/Pidl/Samba4/Python.pm +++ b/tools/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;"); } |