summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2010-08-28 22:00:21 +1000
committerAndrew Tridgell <tridge@samba.org>2010-09-02 13:37:07 +1000
commit58d92cefe266e423f05dec3a2fef91ebc870c350 (patch)
tree5c7ca8b29709eb16bb9f2f62eb09045109f98697 /lib
parente7e39584a9dcfd7d98dc10b88baa53019a77e652 (diff)
downloadsamba-58d92cefe266e423f05dec3a2fef91ebc870c350.tar.gz
samba-58d92cefe266e423f05dec3a2fef91ebc870c350.tar.xz
samba-58d92cefe266e423f05dec3a2fef91ebc870c350.zip
pidl-python: cope with NULL pointers in more places
NULL is converted to Py_None
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 ccf27f5fa0f..c9c6027fe08 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 cdcc57bf85d..caa388ac506 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_ */