diff options
author | Andrew Tridgell <tridge@samba.org> | 2010-08-28 22:00:21 +1000 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 2010-09-02 13:37:07 +1000 |
commit | 58d92cefe266e423f05dec3a2fef91ebc870c350 (patch) | |
tree | 5c7ca8b29709eb16bb9f2f62eb09045109f98697 /lib | |
parent | e7e39584a9dcfd7d98dc10b88baa53019a77e652 (diff) | |
download | samba-58d92cefe266e423f05dec3a2fef91ebc870c350.tar.gz samba-58d92cefe266e423f05dec3a2fef91ebc870c350.tar.bz2 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.c | 20 | ||||
-rw-r--r-- | lib/talloc/pytalloc.h | 4 |
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_ */ |