summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source4/lib/ldb/pyldb.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/source4/lib/ldb/pyldb.c b/source4/lib/ldb/pyldb.c
index 4ff56b4e2b..737d3fbdff 100644
--- a/source4/lib/ldb/pyldb.c
+++ b/source4/lib/ldb/pyldb.c
@@ -1827,9 +1827,12 @@ static PyObject *py_ldb_msg_element_repr(PyLdbMessageElementObject *self)
element_str = talloc_asprintf_append(element_str, ",%s", PyObject_REPR(o));
}
- ret = PyString_FromFormat("MessageElement([%s])", element_str);
-
- talloc_free(element_str);
+ if (element_str != NULL) {
+ ret = PyString_FromFormat("MessageElement([%s])", element_str);
+ talloc_free(element_str);
+ } else {
+ ret = PyString_FromString("MessageElement([])");
+ }
return ret;
}