diff options
author | Jelmer Vernooij <jelmer@samba.org> | 2010-04-15 18:41:56 +0200 |
---|---|---|
committer | Jelmer Vernooij <jelmer@samba.org> | 2010-04-15 18:45:41 +0200 |
commit | 13bbfa3fcabfc97a57ae56ef916bf13137fb5290 (patch) | |
tree | 26be3d8c069a02d8c1a21784e7d5b38bf395e18c /source4/dsdb | |
parent | ce28f854c0c8c62c6f13989ec4d2f9e890ffd0e1 (diff) | |
download | samba-13bbfa3fcabfc97a57ae56ef916bf13137fb5290.tar.gz samba-13bbfa3fcabfc97a57ae56ef916bf13137fb5290.tar.bz2 samba-13bbfa3fcabfc97a57ae56ef916bf13137fb5290.zip |
pydsdb: Fix memory leak on invalid parameters, formatting, trivial
typos.
Diffstat (limited to 'source4/dsdb')
-rw-r--r-- | source4/dsdb/pydsdb.c | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/source4/dsdb/pydsdb.c b/source4/dsdb/pydsdb.c index 39f20672ce..88c62086f3 100644 --- a/source4/dsdb/pydsdb.c +++ b/source4/dsdb/pydsdb.c @@ -191,31 +191,38 @@ static PyObject *py_dsdb_get_oid_from_attid(PyObject *self, PyObject *args) uint32_t attid; struct dsdb_schema *schema; const char *oid; + PyObject *ret; TALLOC_CTX *mem_ctx; WERROR status; + if (!PyArg_ParseTuple(args, "Oi", &py_ldb, &attid)) + return NULL; + mem_ctx = talloc_new(NULL); if (mem_ctx == NULL) { PyErr_NoMemory(); return NULL; } - if (!PyArg_ParseTuple(args, "Oi", &py_ldb, &attid)) - return NULL; - PyErr_LDB_OR_RAISE(py_ldb, ldb); schema = dsdb_get_schema(ldb, NULL); if (!schema) { PyErr_SetString(PyExc_RuntimeError, "Failed to find a schema from ldb \n"); + talloc_free(mem_ctx); return NULL; } - status = dsdb_schema_pfm_oid_from_attid(schema->prefixmap, attid, - mem_ctx, &oid); + + status = dsdb_schema_pfm_oid_from_attid(schema->prefixmap, attid, + mem_ctx, &oid); PyErr_WERROR_IS_ERR_RAISE(status); - return PyString_FromString(oid); + ret = PyString_FromString(oid); + + talloc_free(mem_ctx); + + return ret; } static PyObject *py_dsdb_set_ntds_invocation_id(PyObject *self, PyObject *args) @@ -349,8 +356,8 @@ static PyMethodDef py_dsdb_methods[] = { "Get SID of domain in use." }, { "samdb_ntds_invocation_id", (PyCFunction)py_samdb_ntds_invocation_id, METH_VARARGS, "get the NTDS invocation ID GUID as a string"}, - { "dsdb_get_oid_from_attid", (PyCFunction)py_dsdb_get_oid_from_attid, METH_VARARGS, - NULL }, + { "dsdb_get_oid_from_attid", (PyCFunction)py_dsdb_get_oid_from_attid, + METH_VARARGS, NULL }, { "dsdb_set_ntds_invocation_id", (PyCFunction)py_dsdb_set_ntds_invocation_id, METH_VARARGS, NULL }, |