diff options
author | Noel Power <noel.power@suse.com> | 2019-01-22 18:26:23 +0000 |
---|---|---|
committer | Noel Power <npower@samba.org> | 2019-02-07 13:44:30 +0100 |
commit | a8e10a12493fdb6b8347b14e157aeb619cf2d2da (patch) | |
tree | fce0edcc38dd3b827744708ec748d306c84512e1 /source4 | |
parent | bf91ee0a9727cc392583fe84ad069204be758515 (diff) | |
download | samba-a8e10a12493fdb6b8347b14e157aeb619cf2d2da.tar.gz |
Decrement references to python objects passed to Py_BuildValue
Py_BuildValue when processing format 'O' will
'Pass a Python object untouched (except for its reference count,
which is incremented by one'
Basically this means if you are using a new reference to a PyObject
to pass to BuildValue (to be used with the 'O' format) the reference
*isn't* stolen so you really do need to DECREF it in order to ensure
it gets cleaned up.
Signed-off-by: Noel Power <noel.power@suse.com>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Diffstat (limited to 'source4')
-rw-r--r-- | source4/dns_server/pydns.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/source4/dns_server/pydns.c b/source4/dns_server/pydns.c index a4441ddef56..16d22dfe4b8 100644 --- a/source4/dns_server/pydns.c +++ b/source4/dns_server/pydns.c @@ -100,6 +100,7 @@ static PyObject *py_dsdb_dns_lookup(PyObject *self, struct ldb_context *samdb; PyObject *py_ldb, *ret, *pydn; PyObject *py_dns_partition = NULL; + PyObject *result = NULL; char *dns_name; TALLOC_CTX *frame; NTSTATUS status; @@ -156,7 +157,10 @@ static PyObject *py_dsdb_dns_lookup(PyObject *self, ret = py_dnsp_DnssrvRpcRecord_get_list(records, num_records); pydn = pyldb_Dn_FromDn(dn); talloc_free(frame); - return Py_BuildValue("(OO)", pydn, ret); + result = Py_BuildValue("(OO)", pydn, ret); + Py_CLEAR(ret); + Py_CLEAR(pydn); + return result; } static PyObject *py_dsdb_dns_extract(PyObject *self, PyObject *args) |