]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
pydns: Fix leak of talloc_stackframe() in python bindings
authorAndrew Bartlett <abartlet@samba.org>
Mon, 27 Feb 2017 03:51:45 +0000 (16:51 +1300)
committerAndrew Bartlett <abartlet@samba.org>
Sat, 10 Jun 2017 19:48:20 +0000 (21:48 +0200)
Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
source4/dns_server/pydns.c

index 9842f24edfdd3b55492e29a6779378d80c3392ae..18c3c2953d908913e13ff994136ca99c8f2f5c4c 100644 (file)
@@ -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;
 }