diff options
author | Joseph Sutton <josephsutton@catalyst.net.nz> | 2023-04-24 10:42:39 +1200 |
---|---|---|
committer | Andrew Bartlett <abartlet@samba.org> | 2023-05-16 23:29:32 +0000 |
commit | f573177c352c2df89c7d5ffd425a37b46b12166c (patch) | |
tree | 4b1a02b7ea2cceaf9b9d1ce9ba8241ec4c0d92c4 /source4/librpc/rpc/pyrpc.c | |
parent | 8d6e4473409375f0e62dd06597ca983d22b941ca (diff) | |
download | samba-f573177c352c2df89c7d5ffd425a37b46b12166c.tar.gz |
python: Safely clear structure members
Using Py_CLEAR() ensures that these structures are observed in a
consistent state by any Python code that may run during deconstruction.
Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Diffstat (limited to 'source4/librpc/rpc/pyrpc.c')
-rw-r--r-- | source4/librpc/rpc/pyrpc.c | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/source4/librpc/rpc/pyrpc.c b/source4/librpc/rpc/pyrpc.c index 7b6bcef9eba..61b3c6357b0 100644 --- a/source4/librpc/rpc/pyrpc.c +++ b/source4/librpc/rpc/pyrpc.c @@ -492,8 +492,7 @@ static void py_dcerpc_ndr_pointer_dealloc(PyObject* self) struct py_dcerpc_ndr_pointer *obj = pytalloc_get_type(self, struct py_dcerpc_ndr_pointer); - Py_DECREF(obj->value); - obj->value = NULL; + Py_CLEAR(obj->value); self->ob_type->tp_free(self); } @@ -512,7 +511,7 @@ static int py_dcerpc_ndr_pointer_set_value(PyObject *self, PyObject *value, void struct py_dcerpc_ndr_pointer *obj = pytalloc_get_type(self, struct py_dcerpc_ndr_pointer); - Py_DECREF(obj->value); + Py_CLEAR(obj->value); obj->value = value; Py_INCREF(obj->value); return 0; |