mirror of
https://github.com/samba-team/samba.git
synced 2025-03-05 20:58:40 +03:00
pyldb: p3k readiness: allow single unicode string in msg element
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
This commit is contained in:
parent
2772fa4fbf
commit
bb4ad8dffe
@ -3047,7 +3047,7 @@ static PyObject *py_ldb_msg_element_new(PyTypeObject *type, PyObject *args, PyOb
|
||||
|
||||
if (py_elements != NULL) {
|
||||
Py_ssize_t i;
|
||||
if (PyBytes_Check(py_elements)) {
|
||||
if (PyBytes_Check(py_elements) || PyStr_Check(py_elements)) {
|
||||
char *_msg = NULL;
|
||||
el->num_values = 1;
|
||||
el->values = talloc_array(el, struct ldb_val, 1);
|
||||
@ -3056,12 +3056,17 @@ static PyObject *py_ldb_msg_element_new(PyTypeObject *type, PyObject *args, PyOb
|
||||
PyErr_NoMemory();
|
||||
return NULL;
|
||||
}
|
||||
if (PyBytes_Check(py_elements)) {
|
||||
result = PyBytes_AsStringAndSize(py_elements, &_msg, &size);
|
||||
msg = _msg;
|
||||
} else {
|
||||
msg = PyStr_AsUTF8AndSize(py_elements, &size);
|
||||
result = (msg == NULL) ? -1 : 0;
|
||||
}
|
||||
if (result != 0) {
|
||||
talloc_free(mem_ctx);
|
||||
return NULL;
|
||||
}
|
||||
msg = _msg;
|
||||
el->values[0].data = talloc_memdup(el->values,
|
||||
(const uint8_t *)msg, size + 1);
|
||||
el->values[0].length = size;
|
||||
|
Loading…
x
Reference in New Issue
Block a user