summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorTim Potter <tpot@samba.org>2003-08-04 00:48:49 +0000
committerTim Potter <tpot@samba.org>2003-08-04 00:48:49 +0000
commit5d070d89a86f43e020fcc824476678fe634327d5 (patch)
tree4b9fe65c4efd5f1e335dcbdc9ba0b7af8ac615e3 /source3
parent99a4bb07a9a1664cd0eeb1b5de370b21fb926dc2 (diff)
downloadsamba-5d070d89a86f43e020fcc824476678fe634327d5.tar.gz
samba-5d070d89a86f43e020fcc824476678fe634327d5.tar.bz2
samba-5d070d89a86f43e020fcc824476678fe634327d5.zip
Fix memory leak in py_smb_set_setdesc()
Consistency fixups in py_smb_query_secdesc() Thanks to Brett A. Funderburg for these patches. (This used to be commit 6c33189e50ae3704275198e324fcdb7facd209f7)
Diffstat (limited to 'source3')
-rw-r--r--source3/python/py_smb.c25
1 files changed, 15 insertions, 10 deletions
diff --git a/source3/python/py_smb.c b/source3/python/py_smb.c
index bb84a337c9..e5e6506196 100644
--- a/source3/python/py_smb.c
+++ b/source3/python/py_smb.c
@@ -221,10 +221,10 @@ static PyObject *py_smb_query_secdesc(PyObject *self, PyObject *args,
{
cli_state_object *cli = (cli_state_object *)self;
static char *kwlist[] = { "fnum", NULL };
- PyObject *result;
+ PyObject *result = NULL;
SEC_DESC *secdesc = NULL;
int fnum;
- TALLOC_CTX *mem_ctx;
+ TALLOC_CTX *mem_ctx = NULL;
/* Parse parameters */
@@ -238,7 +238,6 @@ static PyObject *py_smb_query_secdesc(PyObject *self, PyObject *args,
if (cli_is_error(cli->cli)) {
PyErr_SetString(PyExc_RuntimeError, "query_secdesc failed");
- result = NULL;
goto done;
}
@@ -252,7 +251,6 @@ static PyObject *py_smb_query_secdesc(PyObject *self, PyObject *args,
PyErr_SetString(
PyExc_TypeError,
"Invalid security descriptor returned");
- result = NULL;
goto done;
}
@@ -268,11 +266,12 @@ static PyObject *py_smb_set_secdesc(PyObject *self, PyObject *args,
{
cli_state_object *cli = (cli_state_object *)self;
static char *kwlist[] = { "fnum", "security_descriptor", NULL };
+ PyObject *result = NULL;
PyObject *py_secdesc;
SEC_DESC *secdesc;
- TALLOC_CTX *mem_ctx = talloc_init("py_smb_set_secdesc");
+ TALLOC_CTX *mem_ctx = NULL;
int fnum;
- BOOL result;
+ BOOL err;
/* Parse parameters */
@@ -280,20 +279,26 @@ static PyObject *py_smb_set_secdesc(PyObject *self, PyObject *args,
args, kw, "iO", kwlist, &fnum, &py_secdesc))
return NULL;
+ mem_ctx = talloc_init("py_smb_set_secdesc");
+
if (!py_to_SECDESC(&secdesc, py_secdesc, mem_ctx)) {
PyErr_SetString(PyExc_TypeError,
"Invalid security descriptor");
- return NULL;
+ goto done;
}
- result = cli_set_secdesc(cli->cli, fnum, secdesc);
+ err = cli_set_secdesc(cli->cli, fnum, secdesc);
if (cli_is_error(cli->cli)) {
PyErr_SetString(PyExc_RuntimeError, "set_secdesc failed");
- return NULL;
+ goto done;
}
- return PyInt_FromLong(result);
+ result = PyInt_FromLong(err);
+ done:
+ talloc_destroy(mem_ctx);
+
+ return result;
}
static PyMethodDef smb_hnd_methods[] = {