Copy over change from Samba repository:
authorGuy Harris <guy@alum.mit.edu>
Wed, 27 Jul 2016 23:21:46 +0000 (16:21 -0700)
committerGuy Harris <guy@alum.mit.edu>
Wed, 27 Jul 2016 23:22:47 +0000 (23:22 +0000)
  commit ed11ce8f12d567a3e0edc1d24aab1784a171ac33
  Author: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
  Date:   Wed May 4 16:51:37 2016 +1200

    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>
Shouldn't affect us, but it makes diffing cleaner.

Change-Id: I8e681dc79c8f4e62b74e2aa5ac2b4924134735c4
Reviewed-on: https://code.wireshark.org/review/16741
Reviewed-by: Guy Harris <guy@alum.mit.edu>
tools/pidl/lib/Parse/Pidl/Samba4/Python.pm

index 566eaac395c395773c0a231aed440980c5239fb7..07c18de3fb5e3782a936873f58889d9c03d2aecd 100644 (file)
@@ -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) {");