Created attachment 15372 [details] patch that shifts the problem, avoiding the crash but defeating legitimate use This is tricky to fix. The crash happens with something like this: python3 -c'from samba.dcerpc import security;security.descriptor().dacl_add(1)' because dacl_add() just assumes its argument is of the right type. But we can't use pytalloc_get_type() because the object is often not a talloc object -- it is an offset into a talloced array. Specifically, struct security_acl has uint32_t num_aces; struct security_ace *aces; not "struct security_ace **aces", which we would need to have a talloc type for each. We need a means of specifying a python type for an object that doesn't rely on it a talloc name.
A simple along these lines: ace = pytalloc_get_ptr(py_ace); + if (ace == NULL) { } fixes the segfault when python is fed a non-talloc object where it expected a talloc one, but does not ensure it is the right kind of talloc object.