summaryrefslogtreecommitdiff
path: root/source4/dns_server/pydns.c
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2017-02-27 16:51:45 +1300
committerAndrew Bartlett <abartlet@samba.org>2017-06-10 21:48:20 +0200
commit9186cc7143cdeec2233df1b3322297a6974d9d2a (patch)
treeaceecdd787a793f1b53a3bae87b0c59d0d5d150b /source4/dns_server/pydns.c
parent4a437eb4beca6e52ab1e3dfda6427b40af1b06fd (diff)
downloadsamba-9186cc7143cdeec2233df1b3322297a6974d9d2a.tar.gz
pydns: Fix leak of talloc_stackframe() in python bindings
Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Garming Sam <garming@catalyst.net.nz>
Diffstat (limited to 'source4/dns_server/pydns.c')
-rw-r--r--source4/dns_server/pydns.c23
1 files changed, 20 insertions, 3 deletions
diff --git a/source4/dns_server/pydns.c b/source4/dns_server/pydns.c
index 9842f24edfd..18c3c2953d9 100644
--- a/source4/dns_server/pydns.c
+++ b/source4/dns_server/pydns.c
@@ -124,12 +124,14 @@ static PyObject *py_dsdb_dns_lookup(PyObject *self, PyObject *args)
status = dns_common_zones(samdb, frame, &zones_list);
if (!NT_STATUS_IS_OK(status)) {
+ talloc_free(frame);
PyErr_SetNTSTATUS(status);
return NULL;
}
werr = dns_common_name2dn(samdb, zones_list, frame, dns_name, &dn);
if (!W_ERROR_IS_OK(werr)) {
+ talloc_free(frame);
PyErr_SetWERROR(werr);
return NULL;
}
@@ -141,16 +143,19 @@ static PyObject *py_dsdb_dns_lookup(PyObject *self, PyObject *args)
&num_records,
NULL);
if (!W_ERROR_IS_OK(werr)) {
+ talloc_free(frame);
PyErr_SetWERROR(werr);
return NULL;
}
- return py_dnsp_DnssrvRpcRecord_get_list(records, num_records);
+ ret = py_dnsp_DnssrvRpcRecord_get_list(records, num_records);
+ talloc_free(frame);
+ return ret;
}
static PyObject *py_dsdb_dns_extract(PyObject *self, PyObject *args)
{
- PyObject *py_dns_el;
+ PyObject *py_dns_el, *ret;
TALLOC_CTX *frame;
WERROR werr;
struct ldb_message_element *dns_el;
@@ -175,11 +180,14 @@ static PyObject *py_dsdb_dns_extract(PyObject *self, PyObject *args)
&records,
&num_records);
if (!W_ERROR_IS_OK(werr)) {
+ talloc_free(frame);
PyErr_SetWERROR(werr);
return NULL;
}
- return py_dnsp_DnssrvRpcRecord_get_list(records, num_records);
+ ret = py_dnsp_DnssrvRpcRecord_get_list(records, num_records);
+ talloc_free(frame);
+ return ret;
}
static PyObject *py_dsdb_dns_replace(PyObject *self, PyObject *args)
@@ -213,12 +221,14 @@ static PyObject *py_dsdb_dns_replace(PyObject *self, PyObject *args)
status = dns_common_zones(samdb, frame, &zones_list);
if (!NT_STATUS_IS_OK(status)) {
PyErr_SetNTSTATUS(status);
+ talloc_free(frame);
return NULL;
}
werr = dns_common_name2dn(samdb, zones_list, frame, dns_name, &dn);
if (!W_ERROR_IS_OK(werr)) {
PyErr_SetWERROR(werr);
+ talloc_free(frame);
return NULL;
}
@@ -226,6 +236,7 @@ static PyObject *py_dsdb_dns_replace(PyObject *self, PyObject *args)
frame,
&records, &num_records);
if (ret != 0) {
+ talloc_free(frame);
return NULL;
}
@@ -238,9 +249,11 @@ static PyObject *py_dsdb_dns_replace(PyObject *self, PyObject *args)
num_records);
if (!W_ERROR_IS_OK(werr)) {
PyErr_SetWERROR(werr);
+ talloc_free(frame);
return NULL;
}
+ talloc_free(frame);
Py_RETURN_NONE;
}
@@ -275,6 +288,7 @@ static PyObject *py_dsdb_dns_replace_by_dn(PyObject *self, PyObject *args)
frame,
&records, &num_records);
if (ret != 0) {
+ talloc_free(frame);
return NULL;
}
@@ -287,9 +301,12 @@ static PyObject *py_dsdb_dns_replace_by_dn(PyObject *self, PyObject *args)
num_records);
if (!W_ERROR_IS_OK(werr)) {
PyErr_SetWERROR(werr);
+ talloc_free(frame);
return NULL;
}
+ talloc_free(frame);
+
Py_RETURN_NONE;
}