summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/talloc/pytalloc.c20
-rw-r--r--lib/talloc/pytalloc.h4
2 files changed, 24 insertions, 0 deletions
diff --git a/lib/talloc/pytalloc.c b/lib/talloc/pytalloc.c
index ccf27f5fa0..c9c6027fe0 100644
--- a/lib/talloc/pytalloc.c
+++ b/lib/talloc/pytalloc.c
@@ -106,5 +106,25 @@ static void py_cobject_talloc_free(void *ptr)
PyObject *PyCObject_FromTallocPtr(void *ptr)
{
+ if (ptr == NULL) {
+ Py_RETURN_NONE;
+ }
return PyCObject_FromVoidPtr(ptr, py_cobject_talloc_free);
}
+
+PyObject *PyString_FromString_check_null(const char *ptr)
+{
+ if (ptr == NULL) {
+ Py_RETURN_NONE;
+ }
+ return PyString_FromString(ptr);
+}
+
+PyObject *PyUnicode_Decode_check_null(const void *ptr, size_t len,
+ const char *charset, const char *options)
+{
+ if (ptr == NULL) {
+ Py_RETURN_NONE;
+ }
+ return PyUnicode_Decode(ptr, len, charset, options);
+}
diff --git a/lib/talloc/pytalloc.h b/lib/talloc/pytalloc.h
index cdcc57bf85..caa388ac50 100644
--- a/lib/talloc/pytalloc.h
+++ b/lib/talloc/pytalloc.h
@@ -54,4 +54,8 @@ PyObject *py_talloc_default_repr(PyObject *py_obj);
PyObject *PyCObject_FromTallocPtr(void *);
+PyObject *PyString_FromString_check_null(const char *ptr);
+PyObject *PyUnicode_Decode_check_null(const void *ptr, size_t len,
+ const char *charset, const char *options);
+
#endif /* _PY_TALLOC_H_ */