diff options
author | Jelmer Vernooij <jelmer@samba.org> | 2009-08-05 03:34:08 +0200 |
---|---|---|
committer | Jelmer Vernooij <jelmer@samba.org> | 2009-08-05 03:44:25 +0200 |
commit | 46bd2271b24b2b6b68541e867c3e87f7d217267c (patch) | |
tree | 5d8c5b910f3785ca6d0f27a0bef463ff3ddf6330 /source4 | |
parent | 88d206070df8e6f1b9190390ddb13a600b1178e0 (diff) | |
download | samba-46bd2271b24b2b6b68541e867c3e87f7d217267c.tar.gz samba-46bd2271b24b2b6b68541e867c3e87f7d217267c.tar.bz2 samba-46bd2271b24b2b6b68541e867c3e87f7d217267c.zip |
pyldb: Fix reference counting on ldb_message_elements, add extra type
check.
Diffstat (limited to 'source4')
-rw-r--r-- | source4/lib/ldb/pyldb.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/source4/lib/ldb/pyldb.c b/source4/lib/ldb/pyldb.c index 8a061c7e8e..a9425b503e 100644 --- a/source4/lib/ldb/pyldb.c +++ b/source4/lib/ldb/pyldb.c @@ -1394,7 +1394,8 @@ struct ldb_message_element *PyObject_AsMessageElement(TALLOC_CTX *mem_ctx, struct ldb_message_element *me; if (PyLdbMessageElement_Check(set_obj)) - return PyLdbMessageElement_AsMessageElement(set_obj); + return talloc_reference(mem_ctx, + PyLdbMessageElement_AsMessageElement(set_obj)); me = talloc(mem_ctx, struct ldb_message_element); @@ -1544,6 +1545,13 @@ static PyObject *py_ldb_msg_element_new(PyTypeObject *type, PyObject *args, PyOb el->values = talloc_array(el, struct ldb_val, el->num_values); for (i = 0; i < el->num_values; i++) { PyObject *item = PySequence_GetItem(py_elements, i); + if (!PyString_Check(item)) { + PyErr_Format(PyExc_TypeError, + "Expected string as element %d in list", + i); + talloc_free(mem_ctx); + return NULL; + } el->values[i].length = PyString_Size(item); el->values[i].data = talloc_memdup(el, (uint8_t *)PyString_AsString(item), el->values[i].length); |