diff options
author | Tim Potter <tpot@samba.org> | 2003-07-29 00:15:23 +0000 |
---|---|---|
committer | Tim Potter <tpot@samba.org> | 2003-07-29 00:15:23 +0000 |
commit | 4e4e1de9cb170a95faf65195c63815ad58d3769e (patch) | |
tree | 638a2d98046583228bcb24dec42f0eefdce41c9d /source3 | |
parent | 17c6789df138dc685d4da0c940260f1447decac3 (diff) | |
download | samba-4e4e1de9cb170a95faf65195c63815ad58d3769e.tar.gz samba-4e4e1de9cb170a95faf65195c63815ad58d3769e.tar.bz2 samba-4e4e1de9cb170a95faf65195c63815ad58d3769e.zip |
More memory leak fixes from Brett! It turns out PyDict_SetItemString
didn't behave exactly as I thought it did. If you create an item using a
PyFoo_FromBar function you must decrement the reference to that object
afterwards (or use Py_BuildValue).
(This used to be commit 2a960963fbe43de753d44d617a7666a7b258092e)
Diffstat (limited to 'source3')
-rw-r--r-- | source3/python/py_ntsec.c | 39 |
1 files changed, 23 insertions, 16 deletions
diff --git a/source3/python/py_ntsec.c b/source3/python/py_ntsec.c index 47524d8e19..3d408e0bda 100644 --- a/source3/python/py_ntsec.c +++ b/source3/python/py_ntsec.c @@ -58,14 +58,14 @@ BOOL py_from_ACE(PyObject **dict, SEC_ACE *ace) return True; } - *dict = PyDict_New(); - - PyDict_SetItemString(*dict, "type", PyInt_FromLong(ace->type)); - PyDict_SetItemString(*dict, "flags", PyInt_FromLong(ace->flags)); - PyDict_SetItemString(*dict, "mask", PyInt_FromLong(ace->info.mask)); + *dict = Py_BuildValue("{sisisi}", "type", ace->type, + "flags", ace->flags, + "mask", ace->info.mask); - if (py_from_SID(&obj, &ace->trustee)) + if (py_from_SID(&obj, &ace->trustee)) { PyDict_SetItemString(*dict, "trustee", obj); + Py_DECREF(obj); + } return True; } @@ -125,10 +125,6 @@ BOOL py_from_ACL(PyObject **dict, SEC_ACL *acl) return True; } - *dict = PyDict_New(); - - PyDict_SetItemString(*dict, "revision", PyInt_FromLong(acl->revision)); - ace_list = PyList_New(acl->num_aces); for (i = 0; i < acl->num_aces; i++) { @@ -138,7 +134,8 @@ BOOL py_from_ACL(PyObject **dict, SEC_ACL *acl) PyList_SetItem(ace_list, i, obj); } - PyDict_SetItemString(*dict, "ace_list", ace_list); + *dict = Py_BuildValue("{sisN}", "revision", acl->revision, + "ace_list", ace_list); return True; } @@ -181,19 +178,29 @@ BOOL py_from_SECDESC(PyObject **dict, SEC_DESC *sd) *dict = PyDict_New(); - PyDict_SetItemString(*dict, "revision", PyInt_FromLong(sd->revision)); + obj = PyInt_FromLong(sd->revision); + PyDict_SetItemString(*dict, "revision", obj); + Py_DECREF(obj); - if (py_from_SID(&obj, sd->owner_sid)) + if (py_from_SID(&obj, sd->owner_sid)) { PyDict_SetItemString(*dict, "owner_sid", obj); + Py_DECREF(obj); + } - if (py_from_SID(&obj, sd->grp_sid)) + if (py_from_SID(&obj, sd->grp_sid)) { PyDict_SetItemString(*dict, "group_sid", obj); + Py_DECREF(obj); + } - if (py_from_ACL(&obj, sd->dacl)) + if (py_from_ACL(&obj, sd->dacl)) { PyDict_SetItemString(*dict, "dacl", obj); + Py_DECREF(obj); + } - if (py_from_ACL(&obj, sd->sacl)) + if (py_from_ACL(&obj, sd->sacl)) { PyDict_SetItemString(*dict, "sacl", obj); + Py_DECREF(obj); + } return True; } |