pyldb: test return code before trying to talloc_steal
authorMatthieu Patou <mat@matws.net>
Sun, 3 Oct 2010 20:43:33 +0000 (00:43 +0400)
committerMatthieu Patou <mat@sn-devel-104.sn.samba.org>
Mon, 4 Oct 2010 19:42:19 +0000 (19:42 +0000)
Otherwise you can have an error on the talloc_steal as the req can have
been not talloced yet

source4/lib/ldb/pyldb.c

index 57407ba0b649b4055c3eb173ade270491196585d..25f4661dce13e5132148532356d979de1f76048c 100644 (file)
@@ -1212,14 +1212,14 @@ static PyObject *py_ldb_search(PyLdbObject *self, PyObject *args, PyObject *kwar
                                   ldb_search_default_callback,
                                   NULL);
 
-       talloc_steal(req, attrs);
-
        if (ret != LDB_SUCCESS) {
                talloc_free(mem_ctx);
                PyErr_LDB_ERROR_IS_ERR_RAISE(PyExc_LdbError, ret, ldb_ctx);
                return NULL;
        }
 
+       talloc_steal(req, attrs);
+
        ret = ldb_request(ldb_ctx, req);
 
        if (ret == LDB_SUCCESS) {