summaryrefslogtreecommitdiff
path: root/source3/python/py_samr.c
diff options
context:
space:
mode:
authorTim Potter <tpot@samba.org>2002-05-27 06:35:30 +0000
committerTim Potter <tpot@samba.org>2002-05-27 06:35:30 +0000
commit2fe386d9b90c357020bbe4e5e3849d4874bc185c (patch)
tree5b75c92b1a5af61b953dd96a8d0b23b875e15afc /source3/python/py_samr.c
parent343751ca95af59ac771295df45cc1d0a1cda31de (diff)
downloadsamba-2fe386d9b90c357020bbe4e5e3849d4874bc185c.tar.gz
samba-2fe386d9b90c357020bbe4e5e3849d4874bc185c.tar.bz2
samba-2fe386d9b90c357020bbe4e5e3849d4874bc185c.zip
Use new version of open_pipe_creds() function.
Fix memory leaks on error. (This used to be commit b44e82667252c0ff4477d77487ff92b3af8ad418)
Diffstat (limited to 'source3/python/py_samr.c')
-rw-r--r--source3/python/py_samr.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/source3/python/py_samr.c b/source3/python/py_samr.c
index 6256629592..f715f891b4 100644
--- a/source3/python/py_samr.c
+++ b/source3/python/py_samr.c
@@ -276,9 +276,9 @@ static PyObject *samr_connect(PyObject *self, PyObject *args, PyObject *kw)
static char *kwlist[] = { "server", "creds", "access", NULL };
uint32 desired_access = MAXIMUM_ALLOWED_ACCESS;
char *server, *errstr;
- struct cli_state *cli;
+ struct cli_state *cli = NULL;
POLICY_HND hnd;
- TALLOC_CTX *mem_ctx;
+ TALLOC_CTX *mem_ctx = NULL;
PyObject *result = NULL, *creds = NULL;
NTSTATUS ntstatus;
@@ -287,8 +287,7 @@ static PyObject *samr_connect(PyObject *self, PyObject *args, PyObject *kw)
&creds, &desired_access))
return NULL;
- if (!(cli = open_pipe_creds(
- server, creds, cli_lsa_initialise, &errstr))) {
+ if (!(cli = open_pipe_creds(server, creds, PIPE_SAMR, &errstr))) {
PyErr_SetString(samr_error, errstr);
free(errstr);
return NULL;
@@ -312,6 +311,14 @@ static PyObject *samr_connect(PyObject *self, PyObject *args, PyObject *kw)
result = new_samr_connect_hnd_object(cli, mem_ctx, &hnd);
done:
+ if (!result) {
+ if (cli)
+ cli_shutdown(cli);
+
+ if (mem_ctx)
+ talloc_destroy(cli);
+ }
+
return result;
}