From 89440dd617eb4ff64cda8bf97f1f22ddf94bf717 Mon Sep 17 00:00:00 2001 From: Kamen Mazdrashki Date: Mon, 8 Nov 2010 23:40:14 +0200 Subject: s4-pydsdb-py_samdb_ntds_objectGUID(): Avoid potential memory leak in case py_ldb is not a valid LDB --- source4/dsdb/pydsdb.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/source4/dsdb/pydsdb.c b/source4/dsdb/pydsdb.c index e270d7458b..41985ba648 100644 --- a/source4/dsdb/pydsdb.c +++ b/source4/dsdb/pydsdb.c @@ -414,19 +414,18 @@ static PyObject *py_samdb_ntds_objectGUID(PyObject *self, PyObject *args) TALLOC_CTX *mem_ctx; const struct GUID *guid; - mem_ctx = talloc_new(NULL); - if (mem_ctx == NULL) { - PyErr_NoMemory(); - return NULL; - } - if (!PyArg_ParseTuple(args, "O", &py_ldb)) { - talloc_free(mem_ctx); return NULL; } PyErr_LDB_OR_RAISE(py_ldb, ldb); + mem_ctx = talloc_new(NULL); + if (mem_ctx == NULL) { + PyErr_NoMemory(); + return NULL; + } + guid = samdb_ntds_objectGUID(ldb); if (guid == NULL) { PyErr_SetString(PyExc_RuntimeError, "Failed to find NTDS GUID"); -- cgit