1
0
mirror of https://github.com/samba-team/samba.git synced 2025-07-30 19:42:05 +03:00

pyldb: Fix reference counting on ldb_message_elements, add extra type

check.
This commit is contained in:
Jelmer Vernooij
2009-08-05 03:34:08 +02:00
parent 88d206070d
commit 46bd2271b2

View File

@ -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);