summaryrefslogtreecommitdiff
path: root/pidl
diff options
context:
space:
mode:
authorDouglas Bagnall <douglas.bagnall@catalyst.net.nz>2016-05-04 16:51:37 +1200
committerAndrew Bartlett <abartlet@samba.org>2016-05-10 01:43:15 +0200
commited11ce8f12d567a3e0edc1d24aab1784a171ac33 (patch)
tree9277cd9097d016491c7983c3056b9f37029bef40 /pidl
parent2ba83ae49b34812ed165357e2bdcd1c4b627cad4 (diff)
downloadsamba-ed11ce8f12d567a3e0edc1d24aab1784a171ac33.tar.gz
Python pidl: avoid segfault with "del obj->attr"
Deleting an attribute in Python (using the "del" statement) is (at some stages along a winding path, for C objects) converted into setting the attribute to NULL. Not None, actual NULL. The way we handled this NULL was to dereference it. This changes the behaviour to raising an AttributeError, which is more or less what Python does in similar situations with builtin objects. Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Diffstat (limited to 'pidl')
-rw-r--r--pidl/lib/Parse/Pidl/Samba4/Python.pm8
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 9e39167eb7e..f43e4d62443 100644
--- a/pidl/lib/Parse/Pidl/Samba4/Python.pm
+++ b/pidl/lib/Parse/Pidl/Samba4/Python.pm
@@ -1218,6 +1218,14 @@ sub ConvertObjectFromPythonLevel($$$$$$$$)
$pl = GetPrevLevel($e, $pl);
}
+ $self->pidl("if ($py_var == NULL) {");
+ $self->indent;
+ $self->pidl("PyErr_Format(PyExc_AttributeError, \"Cannot delete NDR object: " .
+ mapTypeName($var_name) . "\");");
+ $self->pidl($fail);
+ $self->deindent;
+ $self->pidl("}");
+
if ($l->{TYPE} eq "POINTER") {
if ($l->{POINTER_TYPE} ne "ref") {
$self->pidl("if ($py_var == Py_None) {");